Common verification methods:
checkUserNameflag=false; checkPasswordflag=false; checkPasswordAgianflag=false; checkEmailflag=false; // Username verificationfunction checkUserName() { var username = $("userNeme").value; var zz = /^[A-Za-z0-9]{6,}$/; if (!(username)) { $("userName_warn").innerHTML = "× The username does not meet the specifications"; checkUserNameflag=false; } else { /*$("userName_warn").='blue'; $("userName_warn").innerHTML = "√ Username is available";*/ showUserExist(username); checkUserNameflag=true; } } //Reset promptfunction resetWarn(){ $("userName_warn").innerHTML=""; $("email_warn").innerHTML=""; $("password_warn").innerHTML=""; $("Repassword_warn").innerHTML=""; } // Password verificationfunction checkPassword() { var password1 = $("password").value; if ( >= 6 && <= 15) { checkPasswordflag = true; $("password_warn").='blue'; $("password_warn").innerHTML = " √ Password available "; checkAgianMiMa(); } else { checkPasswordflag = false; $("password_warn").innerHTML = " × Password is at least 6 characters "; } } function checkPasswordAgian() { var password1 = $("password").value; var password2 = $("rePassword").value; if (password1 == password2) { if (password1 == "") { $("Repassword_warn").innerHTML = " × Please enter your password "; checkPasswordAgianflag = false; return; } $("Repassword_warn").='blue'; $("Repassword_warn").innerHTML = "√ Repeat password correctly"; checkPasswordAgianflag = true; } else { checkPasswordAgianflag = false; $("Repassword_warn").innerHTML = " × The password input is different twice "; } } function checkEmail(){ //Verification of email var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; var email=$("email").value; if(!(email)){ checkEmailflag=false; $("email_warn").='red'; $("email_warn").innerHTML = "× The email format does not comply with the specifications"; } else { checkEmailflag=true; $("email_warn").='blue'; $("email_warn").innerHTML = "√ The email address is correct"; } } function submitCheck(){ alert(checkUserNameflag); if(checkUserNameflag==false || checkPasswordflag==false || checkPasswordflag==false ||checkPasswordAgianflag==false || checkEmailflag==false){ return; } } function $(id){ return (id); }
js regular expressions--validation form
Detect mobile phone number: /0?(13|14|15|18)[0-9]{9}/
Detect username: (number, English, Chinese characters, underline, medium horizontal line): /^[A-Za-z0-9_\-\u4e00-\u9fa5]+$/
Password: (number, English, underline, medium horizontal line)/^[A-Za-z0-9_-]+$/
ID card: /\d{17}[\d|x]|\d{15}/
Non-empty:/^\S+$/
IP address: /((?:(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/
The above is the regular expression for JS form data verification introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!