Hi, I'm new to this but I think I found a bug with the email Data Annotation.
I have a property in a c# mvc model as follows:
[DataType( DataType.EmailAddress )]
[Display( Name = "Site Email:" )]
[StringLength( 255 )]
[Email( ErrorMessage = "Invalid Site Email Address" )]
public string SiteEmail { get; set; }
I have just implemented my views to either display or not display certain input fields on the web page. When I don't display this email address, and I post my View back, ModelState.IsValid is failing on this control. You can see that the property has no value, but for some reason, the error message returned is "Invalid Site Email Address".
I think I have resolved my own issue. I had to add a hidden field to represent the value of the property in the view even though I wasn't displaying the control.
Hi, I'm new to this but I think I found a bug with the email Data Annotation.
I have a property in a c# mvc model as follows:
I have just implemented my views to either display or not display certain input fields on the web page. When I don't display this email address, and I post my View back, ModelState.IsValid is failing on this control. You can see that the property has no value, but for some reason, the error message returned is "Invalid Site Email Address".