Enforcing Maximum character length Validation (Maximum of 5 letters).

Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 335
Hear,we will also use Asp.net RegularExpressionValidator control to achieve this task:-

Refer below code:-
<asp:TextBox Id = "txt_employee_code" runat = "server"></asp:TextBox>

<asp:RegularExpressionValidator Display = "Dynamic"
ControlToValidate = "txt_employee_code" Id = "reg_ex_employee_code"
ValidationExpression = "^[\s\S]{0,5}$" runat = "server"
ErrorMessage = "Maximum of 5 letters allowed">

It will allow only 5 letters after that it will give error message as Maximum of 5 letters allowed.

Comments or Responses

Login to post response