1. Detection user name can only be made up of Chinese and English, numbers and underscores, can not use other symbols, the user name is already exist
function Checkloginaccount () {
var msg = ';
var nameid1 = document.getElementById ("login_name"). Value;
if (Nameid1.length < 4 | | nameid1.length > 20) {
msg = "User name length can only be between 4-20-bit characters";
Alert (msg);
return false;
}
else {
for (var index = 0; index < nameid1.length; index++) {
c = Nameid1.charat (index);
c = C.touppercase ();
if (! ( (c >= "A" && C <= "Z") | | (c >= "0" && C <= "9") | | c = = "_" | | c>= "\u4e00" &&c<= "\u9fa5") {
msg = "User name can only be made up of Chinese, English, numerals and underscores, cannot use other symbols";
Alert (msg);
return false;
}
}
}
var params = {loginName: $ (' #login_name '). Val ()};
$.post ("Userregistercheckloginname", params, function (data) {//user name already exists
if (Data.result = = "Error") {
RetVal = false;
msg = "The account already exists, please modify";
Alert (msg);
document.getElementById ("Regnamehint"). InnerHTML = msg;//This sentence is displayed somewhere in the page, usually after the detection input box, but to define DIV or other, id//For Regnamehi Nt
} else if (Data.result = = "Success") {
RetVal = true;
}
}, "JSON");
R Eturn RetVal;
}
2. Detect the password entered two times the password is consistent, whether it conforms to the specifications
function Checkpassword () {
var userpwd = document.getElementById ("pwd"). Value;
var pwdrepeat = document.getElementById ("Rpwd"). Value;
if (Userpwd.length < 6 | | userpwd.length > 20)
{
msg = "Password length 6-20 characters, please re-enter";
Alert (msg);
return false;
} else {
if (userpwd!== pwdrepeat) {
msg = "does not match the password entered for the first time!" ";
Alert (msg);
return false;
}
else {
return true;
}
}
}
3. Check whether the input mobile phone number meets the requirements
function Checkphone () {
var link_phone = document.getElementById ("Link_phone"). Value;
if (link_phone.length! = 11) {
msg = "Cell phone number format is not correct, please re-enter";
Alert (msg);
return false;
}
for (var index = 0; index < link_phone.length; index++) {
c = Link_phone.charat (index);
if (! ( C >= "0" && C <= "9")) {
msg = "Cell phone number format is not correct, please re-enter";
Alert (msg);
return false;
}
}
return true;
}
Note: You need to introduce <script src= "Xx/jquery.js" type= "Text/javascript" ></script>//xx as a relative path before use
JS Script Input Control Summary