There are two ways to verify foreground form data:
The first kind of JS verification :
<script>
function chkinput (form) {
var reg=/\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * * *;
if (!) ( Reg.test (Form.email.value))) {
alert ("Please enter the correct mailbox format!");
Form.email.select ();
return (false);
}
</script>
<form name= "Form1" method= "Post" action= "#" onsubmit= "return Chkinput (This)" >
< Input type= "text" name= "email" size= ">
<input type=" Submit "value=" Submission ">
</form>
Verify that the input conforms to the mailbox format and does not match the pop-up
verification of the second type of HTML5:
<form name= "Form1" method= "Post" action= "#" >
<input type= "text" name= "email" size= "" Required pattern= "\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * ">
<input type=" Submit "value=" Submission ">
</form>
Simply add pattern= "xxxx" (XXX is a regular expression) and required (to determine whether it is empty) can have the following effects
Today's mainstream browsers support HTML5, but some versions of IE are not supported, so verification is the best plus JS verification
The third type of Ajax has no refresh validation:
Verify that the form data already exists in the database, and then make the appropriate reminders to improve the user experience
I first enter the user name that does not exist in the database, as shown below
Enter three more 666, and the user name already exists because there are 666666 in the database
SOURCE Download Address: http://yunpan.cn/cmZZqF7gninRr access password ff4d