javascript - Phone number validation regex with custom constraints -


i should validate phone number. constraints this.

  1. phone numbers should not contain alphabets(silly though mention ;) )
  2. phone number should have minimum 10 characters , maximum 17 characters.
  3. phone number should accept "-" , ".", "+".(not mandatory)
  4. "-" or "." if present, should not in starting of number or ending of number.
  5. only 1 "+" allowed , in starting of number
  6. phone number should not valid if characters entered "-" or "."

so far using following expression.

var phoneexpression = /^(?=.*[0-9])([0-9\.\-\+\ \(\)\/]+)*$/; 

though not meeting constraints. please provide me regular expression.

this 1 should meet constraints except 10 characters , maximum 17 characters because not count + sing if present. if need should duplicate regex alternation |

^\+?[0-9][0-9.-]{8,15}[0-9]$ 

demo


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -