Please enter your phone number: <input name= "" type= "text" id= "Telphone" value= ""/><br/>
Please enter your email address: <input name= "" type= "text" id= "Mail" value= ""/><br/>
Please enter the password for the first time: <input name= "" type= "text" id= "mima1" value= ""/><br/>
Please enter the password for the second time: <input name= "" type= "text" id= "Mima2" value= ""/><br/>
Detect password legality: <input name= "" type= "text" id= "Secury_mima" value= ""/><br/>
<input name= "" type= "button" onclick= "Check ();" value= "Start Detection"/>
<br/>
<br/>
<br/>
<div style= "background: #000" id= "Checktel" ></div>
<div style= "background: #000" id= "Checkmail" ></div>
<div style= "background: #000" id= "CHECKREPSW" ></div>
<div style= "background: #000" id= "CHECKPSW" ></div>
<div style= "background: #000" id= "CHECKUSR" ></div>
</body>
<script>
var xmlHttp; This doesn't explain.
var checkpsw; Global variables for the same password detection
function Createxmlhttp () {
if (window. ActiveXObject) {
xmlhttp= new ActiveXObject (' microsoft.xmlhttp ');
}
else if (window. XMLHttpRequest) {
xmlhttp= new XMLHttpRequest ();
}
}
Detect if the user name is legitimate
function Check_usr (obj) {
var objvalue = Obj.value;
var b=/^[a-za-z\d]\w{2,10}[a-za-z\d]$/;
if (!b.test (ObjValue)) {
document.getelementbyidx_x (' checkusr '). InnerHTML = "<font color= ' #ff0000 ' > Username illegal!</font>";
return false;
}
else {
Createxmlhttp ();
Xmlhttp.open ("GET", "..") /account/check.php?id= "+ ObjValue, True);
Xmlhttp.onreadystatechange = Checkback;
Xmlhttp.send (NULL);
}
}
function Checkback () {
var backvalue = null;
if (xmlhttp.readystate==1)
{document.getelementbyidx_x (' checkusr '). InnerHTML = "<font color= ' #ff0000 ' > Detection ...</font>";}
if (Xmlhttp.responsetext = = 1) {//check.php not registered return 1, registration returns 2
Backvalue = "<font color= ' #00c72e ' > can be used! </font> ";
}else {
Backvalue= "<font color= ' #ff0000 ' > Sorry, it's been registered! </font> ";
}
if (xmlhttp.readystate = = 4) {
document.getelementbyidx_x (' checkusr '). InnerHTML = Backvalue;
}
}
Determine if password entry is legal, one is length, one is no special character
function CHECK_PSW (obj) {
Checkpsw=obj.value;
if (Checkpsw.length > 5 && checkpsw.length<21) {
Document.getelementbyidx_x ("CHECKPSW"). InnerHTML = "<font color= ' #00c72e ' > password can be used!</font>";
}else {
Document.getelementbyidx_x ("CHECKPSW"). Innerhtml= "<font color= ' #ff0000 ' > password does not meet the length requirements!</font>";
}
var b=/^[a-za-z\d]\w{2,10}[a-za-z\d]$/;
if (!b.test (CHECKPSW)) {
document.getelementbyidx_x (' checkusr '). InnerHTML = "<font color= ' #ff0000 ' > Password has illegal character!</font>";
return false;
}else {
Document.getelementbyidx_x ("Checkusr"). Innerhtml= "<font color= ' #ff0000 ' > Password settings meet the requirements </font>";
}
}
Determine if the password input is consistent two times
function CHECK_REPSW (obj1,obj2) {
var Objvalue1=obj1.value;
var Objvalue2=obj2.value;
if (objvalue1==objvalue2) {
Document.getelementbyidx_x ("CHECKREPSW"). Innerhtml= "<font color= ' #00c72e ' > two times input password consistent! </font> ";
}else {
Document.getelementbyidx_x ("CHECKREPSW"). Innerhtml= "<font color= ' #ff0000 ' > two times the password entered is not the same!</font>";
}
}
Determine if the phone number format is legal
function Check_tel (obj) {
var Objvalue=obj.value;
var regx=/^ (?: 13\d|15\d|18[123456789])-?\d{5} (\d{3}|\*{3}) $/;
if (Regx.test (ObjValue)) {
Document.getelementbyidx_x ("Checktel"). Innerhtml= "<font color= ' #00c72e ' > Phone number entered correctly! </font> ";
}else{
Document.getelementbyidx_x ("Checktel"). Innerhtml= "<font color= ' #ff0000 ' > Please enter the correct phone number!</font>";
}
}
Determine if the email address format is legitimate
function Check_mail (obj) {
var Strm=obj.value;
var regm =/^[a-za-z0-9_-][email protected][a-za-z0-9_-]+ (\.[ a-za-z0-9_-]+) +$/;//Verify Mail's regular expression, ^[a-za-z0-9_-]: Must begin with letters, underscores, numbers,
if (!strm.match (REGM))
{
Document.getelementbyidx_x ("Checkmail"). Innerhtml= "<font color= ' #ff0000 ' > email address formatted incorrectly or containing illegal characters!</font>";
} else{
Document.getelementbyidx_x ("Checkmail"). Innerhtml= "<font color= ' #00c72e ' > email address entered correctly! </font> ";
}
}
Click button to start detection
function Check () {
Telphone = document.getelementbyidx_x ("Telphone");
Mail = document.getelementbyidx_x ("Mail");
MIMA1 = document.getelementbyidx_x ("mima1");
MIMA2 = document.getelementbyidx_x ("Mima2");
Secury_mima = document.getelementbyidx_x ("Secury_mima");
Check_tel (Telphone);//Detection phone
Check_mail (mail);//Detection mailbox
CHECK_REPSW (MIMA1,MIMA2);//Detect two times if the password is consistent
CHECK_PSW (Secury_mima);//Check the password is legal
}
</script>
JS Registration detection User name, password, mobile phone number, mailbox