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.

Example of Regular Expression Validation in MVC

In this example I am applying the regular expression validation on name field. As I applied that it can contain only character

Syntax of Regular Expression

		[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:-

		server side validation

		Figure 1

Now enter only character:-

		Regular Expression validation

		Figure 2

Similarly we can create any pattern and can apply on any control using Regular Expression attribute.

Email Address

For any query you can send mail at