javascript - Phone number validation regex with custom constraints -
i should validate phone number. constraints this.
- phone numbers should not contain alphabets(silly though mention ;) )
- phone number should have minimum 10 characters , maximum 17 characters.
- phone number should accept "-" , ".", "+".(not mandatory)
- "-" or "." if present, should not in starting of number or ending of number.
- only 1 "+" allowed , in starting of number
- 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]$
Comments
Post a Comment