Mailbox Regular:
Js:
1 var regemail =/^ ([a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) +/; 2 // Validation 3 if (regemail.test (email)) {4 alert ("Success"); 5 }
Php:
1 $regEmail = "/^ ([a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) +/"; 2 if (preg_match($regEmail$email) {3 echo ' success ' ; 4 }
Mobile phone number Regular:
Js:
1 var regphone =/^1[3|4|5|8][0-9]\d{4,8}$/; 2 if (Regphone.test (phone)) {3 alert ("Success"); 4 }
Php:
1 $regPhone = "/^1[3|4|5|8][0-9]\d{4,8}$/"; 2 if (preg_match($regPhone$phone) {3 echo ' success ' 4
Chinese verification:
Js:
1 var regzn =/^[\u4e00-\u9fa5]{2,}$/; 2 if (Regzn.test (Zn)) {3 alert ("Success"); 4 }
PHP:(Details see: http://blog.sina.com.cn/s/blog_69e1a96d0100vebg.html)
1 $regZn = "/^[\x{4e00}-\x{9fa5}]{2,}$/u"; 2 if (preg_match($regZn$zn)) {3 Echo ' Success '; 4 }
To verify that characters are mailboxes or phone numbers at the same time, you can:
/(^ ([a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) +) | (^1[3|4|5|8][0-9]\d{4,8}$)/
email, mobile phone number, Chinese JS and php regular validation