Regular expression for validating numbers

Rated 4.23/5 based on 849 customer reviews

There are two ways that you can use to validate the phone numbers in PHP.you can either use PHP inbuilt filters or regular expressions for that purpose.Hence, it is very important to validate user input data before using them for various purposes.

where C is the 1–3 digit country code, N is up to 14 digits, and E is the (optional) extension.

It also has the nice side-effect of leaving the country code in

where C is the 1–3 digit country code, N is up to 14 digits, and E is the (optional) extension.

It also has the nice side-effect of leaving the country code in $1 and the local number in $2. =\d$)(1|2[078]|3[0-469]|4[013-9]|5[1-8]|6[0-6]|7|8[1-469]|9[0-58]|[2-9]..)(\d )$ ^ - start of expression (?!

The literal “x” character is required only if an extension is provided. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

If you enter a number then a space it works, but if you just input a space, it does not work. You're right on time again Sonu Kapoor, thanks again! It's very hard to find the right answer on this site, as only a handful of posters actually post the correct answer with no missing (essential) information.

You need TWO validator controls to ensure only numeric values are entered.

||

where C is the 1–3 digit country code, N is up to 14 digits, and E is the (optional) extension.It also has the nice side-effect of leaving the country code in $1 and the local number in $2. =\d$)(1|2[078]|3[0-469]|4[013-9]|5[1-8]|6[0-6]|7|8[1-469]|9[0-58]|[2-9]..)(\d )$ ^ - start of expression (?! The literal “x” character is required only if an extension is provided. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count). If you enter a number then a space it works, but if you just input a space, it does not work. You're right on time again Sonu Kapoor, thanks again! It's very hard to find the right answer on this site, as only a handful of posters actually post the correct answer with no missing (essential) information. You need TWO validator controls to ensure only numeric values are entered.

and the local number in . =\d$)(1|2[078]|3[0-469]|4[013-9]|5[1-8]|6[0-6]|7|8[1-469]|9[0-58]|[2-9]..)(\d )$ ^ - start of expression (?!

The literal “x” character is required only if an extension is provided. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

If you enter a number then a space it works, but if you just input a space, it does not work. You're right on time again Sonu Kapoor, thanks again! It's very hard to find the right answer on this site, as only a handful of posters actually post the correct answer with no missing (essential) information.

You need TWO validator controls to ensure only numeric values are entered.

Leave a Reply