[java]代码库
//定义数组 REresult[0]:true or false REresult[1]:message
var REresult = new Array(2);
// 邮箱格式检查
function REemailCheck(email) {
if (email != "") {
var re = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
var result = re.test(email);
if (result) {
myArray[0]=true;
myArray[1]="格式正确";
} else {
myArray[0]="false";
myArray[1]="邮箱格式错误!";
}
} else {
myArray[0]="false";
myArray[1]="请填写邮箱!";
}
return myArray;
}
//检查密码格式 6-22位密码
function REcheckPassword(password) {
if(password !=""){
var re = /^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~]{6,22}$/;
var result = re.test(password);
document.getElementById('passwordDiv').style.visibility = "visible";
if (result) {
myArray[0]=true;
myArray[1]="格式正确";
} else {
myArray[0]=true;
myArray[1]="密码长度为6-22位!";
}
} else {
myArray[0]="false";
myArray[1]="请填写密码!";
}
return myArray;
}