Friday, 16 August 2013

How to Validate Phone Number Field to accept only numbers and maximum 12 digits?

How to Validate Phone Number Field to accept only numbers and maximum 12
digits?

I am doing validation for 10 digit Indian phone numbers (coding below). I
am accepting digits only. What I can't seem to figure out is how to throw
an error so that if the number entered begins with text or special
characters and also not allow more than 12 Digits. Or either trunacte
numbers to 12 digits if user enters more than 12 digits.
<asp:RegularExpressionValidator ID="phoneregularExpression" runat="server"
ErrorMessage="MoreThan10" EnableClientScript="false"
ControlToValidate="txtphone" Display="Static" Text="Please enter atleast
10 digits" ValidationExpression="^([0-9\(\)\/\+
\-]*)$"></asp:RegularExpressionValidator>
Thanks In Advance.

No comments:

Post a Comment