Registration Verification:
<script language="JavaScript" src="js/jquery-1.9." type="text/javascript"></script> //Verification formfunction vailForm(){ var form = jQuery("#editForm"); if(!vailNickName())return; if(!vailPhone())return; if(!vailPwd())return; if(!vailConfirmPwd())return; if(!vailEmail())return; if(!vailCode())return; if(!vailAgree())return; (); } //Verify the nicknamefunction vailNickName(){ var nickName = jQuery("#nickName").val(); var flag = false; var message = ""; var patrn=/^\d+$/; var length = getNickNameLength(); if(nickName == ''){ message = "The nickname cannot be empty!"; }else if(length<4||length>16){ message = "Nickname 4-16 characters!"; } else if(checkNickNameIsExist()){ message = "The nickname already exists, please re-enter!"; }else{ flag = true; } if(!flag){ jQuery("#nickNameDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#nickNameP").html(""); jQuery("#nickNameP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#nickName").focus(); }else{ jQuery("#nickNameDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#nickNameP").html(""); jQuery("#nickNameP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>This nickname is available");} return flag; } //Calculate the nickname lengthfunction getNickNameLength(){ var nickName = jQuery("#nickName").val(); var len = 0; for (var i = 0; i < ; i++) { var a = (i); //Function format: (rgExp) stringObj is required for string rgExp is required for regular expression//Return value: If it can match, return the result array, return null if it cannot match.if ((/[^\x00-\xff]/ig) != null){ len += 2; }else{ len += 1; } } return len; } //Verify whether the nickname existsfunction checkNickNameIsExist(){ var nickName = jQuery("#nickName").val(); var flag = false; ( { url: "checkNickName?t=" + (new Date()).getTime(), data:{nickName:nickName}, dataType:"json", type:"GET", async:false, success:function(data) { var status = ; if(status == "1"){ flag = true; } } }); return flag; } //Verify mobile phone numberfunction vailPhone(){ var phone = jQuery("#phone").val(); var flag = false; var message = ""; //var myreg = /^(((13[0-9]{1})|159|153)+\d{8})$/; var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-3]{1})|(18[5-9]{1}))+\d{8})$/; if(phone == ''){ message = "The mobile phone number cannot be empty!"; }else if( !=11){ message = "Please enter a valid mobile phone number!"; }else if(!(phone)){ message = "Please enter a valid mobile phone number!"; }else if(checkPhoneIsExist()){ message = "The mobile phone number has been bound!"; }else{ flag = true; } if(!flag){ jQuery("#phoneDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#phoneP").html(""); jQuery("#phoneP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#phone").focus(); }else{ jQuery("#phoneDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#phoneP").html(""); jQuery("#phoneP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>This mobile phone number is available");} return flag; } //Verify whether the mobile phone number existsfunction checkPhoneIsExist(){ var phone = jQuery("#phone").val(); var flag = true; ( { url: "checkPhone?t=" + (new Date()).getTime(), data:{phone:phone}, dataType:"json", type:"GET", async:false, success:function(data) { var status = ; if(status == "0"){ flag = false; } } }); return flag; } //Verify passwordfunction vailPwd(){ var password = jQuery("#password").val(); var flag = false; var message = ""; var patrn=/^\d+$/; if(password ==''){ message = "The password cannot be empty!"; }else if(<6 || >16){ message = "Password 6-16 digits!"; }else if((password)){ message = "The password cannot be all numbers!"; }else{ flag = true; } if(!flag){ jQuery("#passwordDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#passwordP").html(""); jQuery("#passwordP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#password").focus(); }else{ jQuery("#passwordDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#passwordP").html(""); jQuery("#passwordP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>This password is available");} return flag; } //Verify passwordfunction vailConfirmPwd(){ var confirmPassword = jQuery("#confirm_password").val(); var patrn=/^\d+$/; var password = jQuery("#password").val(); var flag = false; var message = ""; if(confirmPassword == ''){ message = "Please enter your confirmation password!"; }else if(confirmPassword != password){ message = "The input of the secondary password is inconsistent, please re-enter!"; }else if((password)){ message = "The password cannot be all numbers!"; }else { flag = true; } if(!flag){ jQuery("#confirmPasswordDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#confirmPasswordP").html(""); jQuery("#confirmPasswordP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#confirm_password").focus(); }else{ jQuery("#confirmPasswordDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#confirmPasswordP").html(""); jQuery("#confirmPasswordP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>The password is correct");} return flag; } //Verify the email addressfunction vailEmail(){ var email = jQuery("#email").val(); var flag = false; var message = ""; var myreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; if(email ==''){ message = "The email cannot be empty!"; }else if(!(email)){ message = "Please enter a valid email address!"; }else if(checkEmailIsExist()){ message = "This email address has been registered!"; }else{ flag = true; } if(!flag){ jQuery("#emailDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#emailP").html(""); jQuery("#emailP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#email").focus(); }else{ jQuery("#emailDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#emailP").html(""); jQuery("#emailP").html("<i class=\"icon-success ui-margin-right10\"> <\/i>This mailbox is available");} return flag; } //Verify whether the email existsfunction checkEmailIsExist(){ var email = jQuery("#email").val(); var flag = false; ( { url: "checkEmail?t=" + (new Date()).getTime(), data:{email:email}, dataType:"json", type:"GET", async:false, success:function(data) { var status = ; if(status == "1"){ flag = true; } } }); return flag; } //Verify verification codefunction vailCode(){ var randCode = jQuery("#randCode").val(); var flag = false; var message = ""; if(randCode == ''){ message = "Please enter the verification code!"; }else if(!checkCode()){ message = "The verification code is incorrect!"; }else{ flag = true; } if(!flag){ jQuery("#randCodeDiv").removeClass().addClass("ui-form-item has-error"); jQuery("#randCodeP").html(""); jQuery("#randCodeP").html("<i class=\"icon-error ui-margin-right10\">&nbsp;<\/i>"+message); //jQuery("#randCode").focus(); }else{ jQuery("#randCodeDiv").removeClass().addClass("ui-form-item has-success"); jQuery("#randCodeP").html(""); jQuery("#randCodeP").html("<i class=\"icon-success ui-margin-right10\">&nbsp;<\/i>"); } return flag; } //Check whether the random verification code is correctfunction checkCode(){ var randCode = jQuery("#randCode").val(); var flag = false; ( { url: "checkRandCode?t=" + (new Date()).getTime(), data:{randCode:randCode}, dataType:"json", type:"GET", async:false, success:function(data) { var status = ; if(status == "1"){ flag = true; } } }); return flag; } //Judge whether to selectfunction vailAgree(){ if(jQuery("#agree").is(":checked")){ return true; }else{ alert("Please confirm whether to read and agree to the XX Agreement"); } return false; } function delHtmlTag(str){ var str=(/<\/?[^>]*>/gim,"");//Remove all html tags var result=(/(^\s+)|(\s+$)/g,"");//Remove the front and back spaces return (/\s/g,"");//Remove the middle spaces in the article}<!DOCTYPE html><html><body><h1>My first paragraph JavaScript</h1><p>Please enter numbers. If the input value is not a number, the browser will pop up a prompt box. </p><input type="text"><script>function myFunction(){var x=("demo").value;if(x==""){ alert("Input cannot be empty"); return;}if(isNaN(x)){ alert("Please enter number"); return;}if(!=6){ alert("Please enter 6 digits"); return;}}</script><button type="button" onclick="myFunction()">Click here</button></body></html>//The verification password is underlined by the numeric letterfunction CheckPwd(pwd) { var validStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~/!@#$%^&*();-+.=,"; for (i = 0; i < ; i++) { if (((i)) == -1) { return false; } } return true; } //Verify the mailbox formatfunction checkemail(email) { var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!(email)) { return false; } return true; } function isEmail(val) { return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_\`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/.test(val); } ///Mobile phone number verificationfunction checktelephone(cellPhone) { var RegCellPhone = /^([0-9]{11})?$/; falg = (RegCellPhone); if (falg == -1) { return false; } else { return true; } } //Get URL parameter valuefunction getParameter(param) { var query = ; var iLen = ; var iStart = (param); if (iStart == -1) return ""; iStart += iLen + 1; var iEnd = ("&", iStart); if (iEnd == -1) return (iStart); return (iStart, iEnd); }
The above code is the js form verification introduced by the editor to you. The code is simple and easy to understand and very practical. I hope it will be helpful to everyone. I also thank you very much for your support for my website!