How to validate Datetime property in my MVC2 Validation.
I have telerik datetime picker to validate
<%= Html.Telerik().DatePicker().Name("EffectiveDate")%>
 [Required(ErrorMessage = "EffectiveDate 开发者_开发百科Must not be empty!")]
            public DateTime EffectiveDate { get; set; }
        }
if I use this code I am not able to validation the EffevtiveDate. Because I am just suspecting that effective date showing as "" instead of null.
how to check "" value using regular expressiong here?
thanks
Try making your model property a nullable DateTime:
[Required(ErrorMessage = "EffectiveDate Must not be empty!")]
public DateTime? EffectiveDate { get; set; }
Then the [Required] attribute should be enough to validate against an empty string.
You could try:
[Required(AllowEmptyStrings = false)]
public DateTime EffectiveDate { get; set; }
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论