WebQQ-like php + js + mysql design-<2> other verification

Source: Internet
Author: User
Let's see if other verifications are easy! & Lt; 2 & gt; Nickname verification Js code [javascript] functioncheckNickname (Nickname) {varxmlhttp; if (window. XMLHttpRequest) {// codeforIE7 +, Firefox, Chrome, Opera, S

Let's see if other verifications are easy!

<2> nickname verification

Js code

[Javascript]
Function checkNickname (Nickname)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{
Document. getElementById ("error2"). innerHTML = "*"; // reset
If (Nickname. length = 0)
{
Document. getElementById ("error2"). innerHTML = "* The nickname cannot be blank! ";
}
Else
{
If (Nickname. length> 16)
{
Document. getElementById ("error2"). innerHTML = "* The nickname cannot exceed 16 characters! ";
}
Else
{
Document. getElementById ("error2"). innerHTML = "* nickname available! ";
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send (); // note that this is different from mailbox verification.
}
Function checkNickname (Nickname)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{
Document. getElementById ("error2"). innerHTML = "*"; // reset
If (Nickname. length = 0)
{
Document. getElementById ("error2"). innerHTML = "* The nickname cannot be blank! ";
}
Else
{
If (Nickname. length> 16)
{
Document. getElementById ("error2"). innerHTML = "* The nickname cannot exceed 16 characters! ";
}
Else
{
Document. getElementById ("error2"). innerHTML = "* nickname available! ";
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send (); // note that this is different from mailbox verification.
}

 

<3> Password verification

Js code

[Javascript]
Function checkPwd1 (password1)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{Document. getElementById ("error3"). innerHTML = "*";
Document. getElementById ("password2"). value = "";
Document. getElementById ("error4"). innerHTML = "*";
If (password1.length = 0)
{
Document. getElementById ("error3"). innerHTML = "* The password cannot be blank! ";

}
Else
{
If (password1.length <6 | password1.length> 16)
{
Document. getElementById ("error3"). innerHTML = "* The password is 6-16 characters long! ";

}
Else
{
Var reg =/[a-zA-Z0-9]/; // use the regular expression www.2cto.com in js
If (reg. test (password1 ))
{
Document. getElementById ("error3"). innerHTML = "* The password is available! ";
}
Else
{
Document. getElementById ("error3"). innerHTML = "* The password is unavailable! ";

}
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}
Function checkPwd1 (password1)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{Document. getElementById ("error3"). innerHTML = "*";
Document. getElementById ("password2"). value = "";
Document. getElementById ("error4"). innerHTML = "*";
If (password1.length = 0)
{
Document. getElementById ("error3"). innerHTML = "* The password cannot be blank! ";

}
Else
{
If (password1.length <6 | password1.length> 16)
{
Document. getElementById ("error3"). innerHTML = "* The password is 6-16 characters long! ";

}
Else
{
Var reg =/[a-zA-Z0-9]/; // use regular expressions in js
If (reg. test (password1 ))
{
Document. getElementById ("error3"). innerHTML = "* The password is available! ";
}
Else
{
Document. getElementById ("error3"). innerHTML = "* The password is unavailable! ";

}
}
}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}


<4> repeated password verification

Js code

[Javascript]
Function checkPwd2 (password2)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{Document. getElementById ("error4"). innerHTML = "*";
If (password2.length = 0)
{
Document. getElementById ("error4"). innerHTML = "* confirm the password! ";

}
Else
{
If (password2! = Document. getElementById ("password1"). value)
{
Document. getElementById ("error4"). innerHTML = "* The two passwords are inconsistent! ";

}
Else
{
Document. getElementById ("error4"). innerHTML = "* consistent password input! ";
}

}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}
Function checkPwd2 (password2)
{
Var xmlhttp;
If (window. XMLHttpRequest)
{// Code for IE7 +, Firefox, Chrome, Opera, Safari
Xmlhttp = new XMLHttpRequest ();
}
Else
{// Code for IE6, IE5
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Xmlhttp. onreadystatechange = function ()
{
If (xmlhttp. readyState = 4 & xmlhttp. status = 200)
{Document. getElementById ("error4"). innerHTML = "*";
If (password2.length = 0)
{
Document. getElementById ("error4"). innerHTML = "* confirm the password! ";

}
Else
{
If (password2! = Document. getElementById ("password1"). value)
{
Document. getElementById ("error4"). innerHTML = "* The two passwords are inconsistent! ";

}
Else
{
Document. getElementById ("error4"). innerHTML = "* consistent password input! ";
}

}
}
}
Xmlhttp. open ("GET", "index. php", true );
Xmlhttp. send ();
}


How are you doing? it's quite simple! (To be continued)

 

From wyzhangchengjin123

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.