Ajax authentication username 2-PHP source code

Source: Internet
Author: User
Ec (2); now let's check. js file code. functionc () {& nbsp; varuid & nbsp; document. getElementById (uid ). value; & nbsp; varpwd & nbsp; document. getElementById (password ). value; & nbsp; varpwd script ec (2); script

Now let's take a look at the check. js file code.

Function c (){
Var uid = document. getElementById ('uid'). value;
Var pwd = document. getElementById ('Password'). value;
Var pwd2 = document. getElementById ('password2 '). value;
Var mo = document. getElementById ('M'). value;
Var name = document. getElementById ('name'). value;

If (uid = ''| uid. length> 12 | uid. length <3 ){
Document. getElementById ('U _ info'). innerHTML ='

The length of the nickname is 3-12 characters!

';
Return false;
} Else {
Document. getElementById ('U _ info'). innerHTML ='

Username must be 3-12 characters long

';
}


If (pwd = ''| pwd! = Pwd2 | pwd. length <6 | pwd. length> 12 ){
Document. getElementById ('P _ info'). innerHTML ='

The password cannot be blank or the password entered twice is inconsistent! ';
Return false;
} Else {
Document. getElementById ('P _ info'). innerHTML ='

';
Document. getElementById ('P _ info1 '). innerHTML ='

';
}

If (mo. match (/^ [0-9] {3, 4}-[0-9] {7, 8} $/) | mo. match (/^ (d {3}) | (d {3 }-))? 13d {9 }$ /)){
Document. getElementById ('m _ info'). innerHTML ='

';
} Else {
Document. getElementById ('m _ info'). innerHTML ='

Phone 13875888888 and landline (0731-888888 )';
Return false;
}

If (name = ''| name. length> 12 | name. length <2 ){
Document. getElementById ('n' _ info'). innerHTML ='

Enter your real name! ';
Return false;
} Else {
Document. getElementById ('n' _ info'). innerHTML ='

';
}


}

Var xmlHttp = false;

Function ajaxcreate (){

Try {
XmlHttp = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
Try {
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e2 ){
XmlHttp = false;
}
}

If (! XmlHttp & typeof XMLHttpRequest! = 'Undefined '){
XmlHttp = new XMLHttpRequest ();
}
If (! XmlHttp) {alert ('create Xmlhttp Fail '); return false ;}
}


Function ajax (){
Ajaxcreate ();
Var xmvalue = document. getElementById ("uid"). value;
Var url = "ajax_check.php? Txt = "+ encodeURI (xmvalue );
If (xmvalue = null | xmvalue. length> 20 | xmvalue = "") return false;
XmlHttp. open ("POST", url, true );
XmlHttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ");
XmlHttp. send (xmvalue );
XmlHttp. onreadystatechange = returnstate;
}
Function returnstate (){
If (xmlHttp. readyState! = 4 ){
Document. getElementById ("u_info"). innerHTML ="

Verifying. Please wait...

";
}
If (xmlHttp. readyState = 4 ){
Document. getElementById ("u_info"). innerHTML = xmlHttp. responseText;
}
}

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.