Regular expression for Phone Numbers with different lengths

xccdark

New Member
I searched on Google for phone number regex validations but haven't been able to make it work based on my requirements.Basically, I have three separate sets of rules for the prefix:
  • For 10 digit numbers I need to make sure the first 3 are numbers starting from 2-9.
  • For 11 digit numbers I need to make sure the first 4 are numbers starting from 1-9.
  • For for anything greater than 12 digits I need to make sure the first 7 are numbers from 0-9.
After that I can allow letters like 1888GOSUPER or something like that (this would fall under the second condition)This is what I have so far but I am not certain if I have covered everything:\[code\]var reg10 = /^[2-9]{3}[a-z0-9]+$/i;var reg11 = /^[1-9]{4}[a-z0-9]+$/i;var reg12plus = /^[0-9]{7}[a-z0-9]+$/i;\[/code\]
 
Back
Top