Amit Ranjan Amit Ranjan - 1 year ago 134
C# Question

Requires regex for US Phone Format

I need a regex that will match the US phone in a slightly different manner. Actually, on my page i have textbox for taking input, there i had place regular expression validator and the regex to validate the zip code in

. Till here everything was fine. Later on we added MaskedEditor extender to avoid manually adding - in between the codes of phone number. Also the ClearMaskOnLostFocus is set to false. So every time we have
in our textbox. And my validator is now always validating its against invalid input.

So finally i would like say, i need a regex that will match if my phone is a valid US phone and also passes
, instead of the two it will break..

[Existing Regex]


Answer Source

Just use the following:

(<your current regex>)|(___-___-____)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download