[^XYZ]: Match any one of the characters except in brackets is equivalent to [0-9]
The username is made up of 6-18-digit alphanumeric underscores and cannot be preceded by a number
Match a 163 email address
var r_163_email=/^\w+@163 (\.) com$/
Matching a suffix name may be. com|.net|.cn|.edu
var email=/^\w+@\w+ (\.) com|net|cn|edu$/
Required to enter a valid age section
var r_age=/^\d{1,2}$/
if (age>=18&&age "=100")
Verify mobile phone Number: 11 digits 13 15 18 Start
var r_tel=/^1[3,5,8]\d{9}$/
Verify ID number 18 digits or 17 digits plus an X
var r_s=/^\d{18}|\d{17}x$/i
Verify Chinese var reg=/^[\u4e00-\u9fa5]{2,17}$/
Php
$reg = "/^[\x{4e00}-\x{9fa5}]$/u"
<span style= "FONT-SIZE:24PX;" > Below is an example of:</span> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
php Regular validation
<?php header ("Content-type:text/html;charset=utf8");
Var_dump ($_post);d ie; Array (5) {["uname"]=> string (9) "Liu Weishu" ["Uqq"]=> string (a) "1111111111" ["Uemail"]=> string (12) "66555@" Qq.com "[Utel"]=> string (one) "15863162320" ["Uinfo"]=> string (48) "Place to begin a holiday to open activity healthy words Summary"} empty ($_post["uname"])? $
Uname= "": $uname =$_post["uname"];
Empty ($_post["Uemail"])? $uemail = "": $uemail =$_post["Uemail"];
Empty ($_post["Utel"])? $utel = "": $utel =$_post["Utel"];
Empty ($_post["UQQ"])? $uqq = "": $uqq =$_post["UQQ"];
Empty ($_post["Uinfo"])? $uinfo = "": $uinfo =$_post["Uinfo"];
Verify name $reg = "/^[\x{4e00}-\x{9fa5}]{2,3}$/u";
if (!preg_match ($reg, $uname)) {echo "User name should be 2-3 characters";d ie;
Header ("refresh:1;url=form.html"); //Verify Mailbox $reg = "/^ (\w+@\w+ (\.)
COM|NET|CN) $/";
if (!preg_match ($reg, $uemail)) {echo mailbox must contain @ and end with COM; header ("refresh:1;url=form.html"); die;
/Verify the landline number $reg = "/^\d{11}$/";
if (!preg_match ($reg, $utel)) {echo "landline number in 010-22222222 format"; Header ("refresh:1;url=form.html"); die; }//Verify QQ number
$reg = "/^\d{5,11}$/";
if (!preg_match ($reg, $uqq)) {echo "QQ must be a 5-11-digit pure number"; Header ("refresh:1;url=form.html"); die;
}//Authentication profile/* $reg = "/^[\x{4e00}-\x{9fa5}]{10,100}\w+/u";
if (!preg_match ($reg, $uinfo)) {echo "Introduction should be 10-100 Chinese characters";d ie;
Header ("refresh:1;url=form.html");
///Connection Database $link =mysql_connect (' 127.0.0.1 ', ' root ', ' root ') or Die ("Connection failed");
Select Database mysql_select_db (' Kaoshi ', $link);
Sets the character set mysql_query ("Set names UTF8"); Write SQL statements $sql = "INSERT into Zhuce (c_name,c_qq,c_email,c_tel,c_info) VALUES (' $uname ', ' $uqq ', ' $uemail ', ' $utel ', ' $
Uinfo ') ";
echo $sql;d ie;
$rel =mysql_query ($sql);
if ($rel) {echo "registered successfully"; Header ("refresh:1;url=show.php");
}else{echo "registration failed"; Header ("refresh:1;url=form.html"); ?>
The above is a small series to introduce Ajax and PHP regular expression verification form and verification code, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!