JS Registration detection User name, password, mobile phone number, mailbox

Source: Internet
Author: User

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 your password for the first time:<input name=""Type="text"Id="MIMA1"Value=""/><br/>Please enter your password for the second time:<input name=""Type="text"Id="Mima2"Value=""/><br/>To detect if a password is valid:<input name=""Type="text"Id="Secury_mima"Value=""/&GT;&LT;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>varXmlHttp;//this doesn't explain .varCHECKPSW;//Global variables for the same password detectionfunction Createxmlhttp () {if(window. ActiveXObject) {xmlHttp=NewActiveXObject ('Microsoft.XMLHTTP'); } Else if(window. XMLHttpRequest) {xmlHttp=NewXMLHttpRequest ();}}//detect if the user name is legitimatefunction check_usr (obj) {varObjValue =Obj.value;varb=/^[a-za-z\d]\w{2,Ten}[a-za-z\d]$/; if(!b.test (ObjValue)) {document.getelementbyidx_x ('checkusr'). InnerHTML ="<font color= ' #ff0000 ' > user name illegal!</font>"; return false; } Else{createxmlhttp (); Xmlhttp.open ("GET",".. /account/check.php?id="+ ObjValue,true); Xmlhttp.onreadystatechange=Checkback; Xmlhttp.send (NULL); }}function Checkback () {varBackvalue =NULL; if(xmlhttp.readystate==1) {document.getelementbyidx_x ('checkusr'). InnerHTML ="<font color= ' #ff0000 ' > Detection in ...</font>";} if(Xmlhttp.responsetext = =1) {//check.php not registered return 1, registration returned 2Backvalue ="<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 characterfunction check_psw (obj) {CHECKPSW=Obj.value;if(Checkpsw.length >5&& checkpsw.length< +) {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>"; } varb=/^[a-za-z\d]\w{2,Ten}[a-za-z\d]$/; if(!b.test (CHECKPSW)) {document.getelementbyidx_x ('checkusr'). InnerHTML ="<font color= ' #ff0000 ' > Password has illegal characters!</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 timesfunction CHECK_REPSW (obj1,obj2) {varobjvalue1=Obj1.value;varObjvalue2=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 legalfunction Check_tel (obj) {varObjvalue=Obj.value;varregx=/^ (?: -\d| the\d| -[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 legitimatefunction Check_mail (obj) {varstrm=Obj.value;varREGM =/^[a-za-z0-9_-][email protected][a-za-z0-9_-]+ (\.[ a-za-z0-9_-]+) +$/;//Verify mail 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 is malformed or contains illegal characters!</font>"; } Else{document.getelementbyidx_x ("Checkmail"). innerhtml="<font color= ' #00c72e ' > email address entered correctly! </font>"; }}//Click button to start detectionfunction 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 PhoneCheck_mail (mail);//Check MailboxCHECK_REPSW (MIMA1,MIMA2);//detect if two passwords are consistentCHECK_PSW (Secury_mima);//detect if the password is legitimate}</script>

JS Registration detection User name, password, mobile phone number, mailbox

Related Article

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.