I need to build a regex to validate all types of phone numbers which includes + ( ) . -
Thanks to Google and stack overflow and i got a regex
/^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\./0-9]*$/g
to validate all phone numbers.
But while validating +(123 456-7890
the above regex not works as expected.
So I modified the above regex as
/^\+?([(]{1}[0-9]{1,3}[)]{1}|[0-9]{1,3})([-\s0-9]*|[.\s0-9]*)\d+$/
and it works fine.
Now I need to restrict the user from entering consecutive -
and dots(.)
So I manually validating that
if(HomePhone.indexOf("..") > -1 && HomePhone.indexOf("--") > -1)
return false;
Could anyone help me to solve the above issue using a single regex by improving it..?
Thanks in Advance