My friend need a validation with these features:
1) always should start with a letter "E";
2) Followed by 4 digit number (0-9);
3) Hyphen ("-");
4) 3 digit number (0-9), followed by four zeros (0000);
5) Hyphen ("-");
6) 4-digit number (0-9);
7) Hyphen ("-");
8) 3-digit number (0-9)
9) Hyphen ("-");
10) "2011" (Current Year)
Real Valid Examples:
E1234-123-1230000-1234-123-2011
E9912-876-9810000-8888-765-2011
E0170-222-3330000-4200-839-2011
E9999-999-9990000-9999-999-2011
E0000-000-0000000-0000-000-2011
when she approaches me with this,i feel like it will eat my ass... :) anyway i plan to make a try She need it in client side not server side validation.i tried in JavaScript but on some condition its fails.After that i try it in Regular Expression. 'n i did it. :)
Code:
<asp:TextBox ID="txt_validation" runat="server" ></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txt_validation" ErrorMessage="Error on format"
ValidationExpression="[E][0-9]{4}[-][0-9]{3}[-][0-9]{3}(0000)[-][0-9]{4}[-][0-9]{3}[-](2011)"></asp:RegularExpressionValidator>
take a tour over this code. u can simply understand. if u can't contact me i will guide u.
Stay Tune...
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment