Written By:- Isha Malhotra
In my last article series I explained the server side Required, Range and Compare validation. In this article I am going to explain the Regular Expression Validation.
Regular Expression validation is used to validate the pattern like email address, website etc.
In this example I am applying the regular expression validation on name field. As I applied that it can contain only character
[RegularExpression("^[a-zA-Z]{1,20}$",ErrorMessage="Kindly Enter only Alphabet")]
public string stu_name { get; set; }
Now execute this code and you will get following output:-
Figure 1
Now enter only character:-
Figure 2
Similarly we can create any pattern and can apply on any control using Regular Expression attribute.
For any query you can send mail at info@techaltum.com
Thanks