Front desk form data validation

Source: Internet
Author: User

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








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.