want to validate indian vehicle No

Posted by Navalemanoj0405 under Regular Expressions on 5/4/2011 | Points: 10 | Views : 6821 | Status : [Member] | Replies : 4
Dear All
I want to validate indian vehicle No Using RegularExpressionValidator in asp.net
If it is pssible please revert

format can be "MH 01 SS 1111 " this
thanks...




Responses

Posted by: Bugwee on: 5/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

try this
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Format"

ControlToValidate="TextBox2" ValidationExpression="^\w{2} \d{2} \w{2} \d{4}" SetFocusOnError="true">
</asp:RegularExpressionValidator>


Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/4/2011 [Member] Starter | Points: 25

Up
0
Down
@Dear Bugwee as the letters after the TWO digits are not of fixed length, your expression wil not work for some old numbers and ofcourse for new numbers which is having three letters or may be more in due course of time.
Actually the number length increase when all the combination run out. :)
Thanks,
Debata

Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bugwee on: 5/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Ndebata,

I'm sorry, I'm not from India. I thought that vehicle number format is fixed "MH 01 SS 1111" . :)

Regards,
Bugwee




Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bugwee on: 5/4/2011 [Member] Starter | Points: 25

Up
0
Down
i hope this one would do

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Format"

ControlToValidate="TextBox2" ValidationExpression="^\w{2} \d{2} \w{2,} \d{4}" SetFocusOnError="true">
</asp:RegularExpressionValidator>


or

 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Format"

ControlToValidate="TextBox2" ValidationExpression="^[a-zA-z]{2} \d{2} [a-zA-Z]{2,} \d{4}" SetFocusOnError="true">
</asp:RegularExpressionValidator>


Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response