javascript - Improved phone validation pattern -
how write pattern, me use such inputs valid:
+ 11111111 + 11 1 1 1 1 + 11 (11) 11 21 + 11 (1-1) 11 1 1 etc
main troule in must use 1 + (which first) 1 (, ), , multiple time -, but! 2 time -- wrong, 1-2-1 valid
only 1 single space valid mean 11 1 2 3
invalid
is real write such huge pattern?
now use 1 of patterns:
[\+]\d{2}[\(]\d{2}[\)]\d{4}[\-]\d{4} ^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$ \d{3}[\-]\d{3}[\-]\d{4}
from here: http://html5pattern.com/phones
but there little bit to-hardcoded, need flexible solution, based on examples above...
Comments
Post a Comment