First paste out the JS code
| The code is as follows |
Copy Code |
<script> function Check () { Name=document.getelementbyidx_x_x ("Fzrxm"). Value; if (name== "") { Alert ("Enter your name!") ") return false; }
Re =/^1\d{10}$/ Tel=document.getelementbyidx_x_x ("Lxdh"). Value; if (Re.test (tel)) {
} else { Alert ("Please enter the correct cell phone number!") "); return false; }
EM =/^ ([a-za-z0-9_\.\-]) +\@ (([a-za-z0-9\-]) +\.) + ([a-za-z0-9]{2,4}) +$/; Eml=document.getelementbyidx_x_x ("Lxqq"). Value; if (Em.test (EML)) {
}else{ Alert ("Please enter the correct mailbox!") "); return false; }
} </script> |
PHP validation
| The code is as follows |
Copy Code |
$email = "tanklo_--vehy@yahoo.com.cn"; function Check_email ($email) { $pattern _test = "/([A-z0-9]*[-_.]? [a-z0-9]+) *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[.] [A-z] {2,3} ([.] [A-z] {2})? /I "; Return Preg_match ($pattern _test, $email); } echo Check_email ($email); function Is_mobile ($STR) { Return Preg_match (/^ (d{3}) | ( d{3}-))? 13d{9}$/", $STR); }
|
Next, when the form form is submitted, add
| code is as follows |
copy code |
| <form action= "/plus/diy.php" enctype= "Multipart/form-data" method= "POST" onsubmit= "return check ()" |