Submission of jquery login registration content

Source: Internet
Author: User

Login registration in the Web page is very common, but in the project, I was the first contact to register the content of the submission, so I tidy up, I will introduce the contents of my collation.

First of all, in the front page to write out the login required to register the input box, this is the basic content, here is not detailed. I then began to introduce the content of the login registration, which I divided into the following sections:

1, registration of the submission of the need for all the content is not empty and correct before you can submit up, otherwise there is a blank reminder or error reminder! So, set a flag value, first set the flag value to 1, but whenever a blank or error is filled in, the flag value is set to 0, and only if the flag is 1 o'clock to submit the data, the code is as follows:

if (flag) {

$ ("form"). Submit ();

}

2, the verification, the name, verification code, such as the use of NULL, password, mobile phone number, mailbox, QQ and other use of the regular judge format is correct:

A, the correct format is defined first:

var flag = 1;
$ (". Errortips"). Remove ();
var Regtel =/^[0-9a-za-z]+@ ([0-9a-za-z]+) [.]) +[a-z]{2,4}$/i;
var regmail =/.+@.+\. [A-za-z] {2,4}$/;
var regqq=/[1-9][0-9]{4,}/;
var regpsw =/^[0-9a-za-z]{6,16}/;
b, and then judge the name, Verification code:

If ($ (". Name"). val () = "") {
Flag=0
var text = "<span class= ' red-tips errortips ' > Please fill in name </span>";
$ (". Name"). Parent (). append (text);
}
if ($ (". Code"). val () = "" "{
flag=0
var text =" <span class= ' red-tips errortips ' > Please complete the Verification code </span > ";
$ (". Code"). Parent (). append (text);
}
C, last defined regular password, and so on:

if (!) ( Regpsw.test ($ (". Password"). Val ())) {
flag=0;
var text = "<span class= ' red-tips errortips ' > Please fill in the correct password (1, length 6-16 characters, 2, only digital and English composition) </span>";
$ (". Password"). Parent (). append (text);
}
if ($ (". Confirm_password"). Val ()!==$ (". Password"). Val ()) {
flag=0;
var text = "<span class= ' red-tips errortips ' > two times password fill inconsistent </span>";
$ (". Confirm_password"). Parent (). append (text);
}
if ($ (". Role"). Val () = "") {
flag=0;
var text = "<span class= ' red-tips errortips ' > Please fill in role information </span>";
$ (". Role"). Parent (). append (text);
}
if (!) ( Regqq.test ($ (". QQ"). Val ())) {
flag=0;
var text = "<span class= ' red-tips errortips ' > Please correct QQ number </span>";
$ (". QQ"). Parent (). append (text);
}
In addition, a blank reminder, error reminder is defined and appended with append (text) when it is judged to be an error or blank:

var text = "<span class= ' red-tips errortips ' > Please correct QQ number </span>";
$ (". QQ"). Parent (). append (text);

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.