There are mazor role of Data Annotation in asp.net mvc. It is used to validate the properties when designing the model page. This validation is used in both side, client side as well as server side. There are some Data Annotation used in mvc is given below,
Required :
It is used to specify a property as required.
exp. [Required(ErrorMessage='Full Name is Required')]
RegularExpression
It is used to specifies the regular expression to validate the value of the property.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Data Annotation in MVC:
There are mazor role of Data Annotation in asp.net mvc. It is used to validate the properties when designing the model page. This validation is used in both side, client side as well as server side. There are some Data Annotation used in mvc is given below,
Required :
It is used to specify a property as required.
RegularExpression
It is used to specifies the regular expression to validate the value of the property.
exp. - [RegularExpression('[a-z]', ErrorMessage = 'Invalid input characters')]Range :
It specifies the Range of values which provide this property
StringLength :
Specifies the Min length & Max length for a given string property.
MaxLength :
Specifies the Max length for the entered property value.
MinLength :
It is used to check for minimum length of property value.