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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -