The collection of two mobile phone number verification code, one is the front desk with jquery verification and then use the background PHP Tutorial code to verify the phone number is legitimate, I hope it is useful to everyone.
Front-end code I use Jquery.validate.js, the code is as follows:
JavaScript code
This is just an imprecise validation, and can only be verified to a range, so the focus is still behind.
PHP code
$mobilephone =trim ($_post["Smmobilephone"]);
Regular verification of mobile phone numbers
if (Preg_match ("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/", $mobilephone)) {
Validation by
}else{
Cell phone number format is incorrect
}
See Example
Regular expressions
$tel = "15558530459";//The author's mobile phone number, if there is doubt can contact me by phone, or QQ contact me, my QQ is mezongzi@qq.com
if (strlen ($tel) = = "11")
{
The upper part of the judging length is not 11 bit
$n = Preg_match_all ("/13[123569]{1}d{8}|15[1235689]d{8}|188d{8}/", $tel, $array);
/* Next Regular expression ("/131,132,133,135,136,139 begins followed by any 8 as number ' | ' (or meaning)
* 151,152,153,156,158.159 the beginning of the following arbitrary 8 for the number
* or a 188 start followed by any number of 8, matching any one of the groups passed
* /")*/
Var_dump ($array); See if it's found, and if it does, it will output the phone number.
}else
{
echo "Length must be 11 bits";
}
/*
* Although it looks more complicated, clear understanding!
* If there is better, can be posted out, share happiness!
* */
?>
http://www.bkjia.com/PHPjc/631333.html www.bkjia.com true http://www.bkjia.com/PHPjc/631333.html techarticle The collection of two mobile phone number verification code, one is the front desk with jquery verification and then use the background PHP Tutorial code to verify the phone number is legitimate, I hope it is useful to everyone. Front-end code I use JQ ...