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