I am trying to validate phone number using regex, and I want to create a phone number format like this:
(+971 12 123 1234)
Can anyone help me do this?
I am trying to validate phone number using regex, and I want to create a phone number format like this:
(+971 12 123 1234)
Can anyone help me do this?
Try this way
var phone_regex = /^\(\d{3]\ \d{2]\ \d{3]\ \d{4]\)$/;
More Detail to refer
http://eisabainyo.net/weblog/2009/04/30/10-examples-of-basic-input-validation-in-javascript/
^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$
This will a Help for you.