Reputation: 20031
I am using following Validation Express for phone number on web application
ValidationExpression="^([\+]?[0-9]{1,3}[\s.-][0-9]{1,12})([\s.-]?[0-9]{1,4}?)$"
<asp:RegularExpressionValidator ID="Phone" runat="server" ErrorMessage="*" ControlToValidate="txt_Phone" ValidationExpression="^([\+]?[0-9]{1,3}[\s.-][0-9]{1,12})([\s.-]?[0-9]{1,4}?)$"></asp:RegularExpressionValidator>
it validate following phone numbers
local numbers 00 1234567, 000 1234567 or 04-1234567, 000-1234657
international numbers +000 00000000, +000-00000000, +00 00000000,
i also want to support numbers with out white space & with 00 for international numbers example
001234567, 0012312345678, 00123 12345678, 001212345678
Upvotes: 0
Views: 6560
Reputation: 174826
Just make the in-between [\s.-]
pattern as optional and add an optional 00
at the start.
^([\+]?(?:00)?[0-9]{1,3}[\s.-]?[0-9]{1,12})([\s.-]?[0-9]{1,4}?)$
Upvotes: 2