各种check

各种check,用onblur触发

function checkPhoneNum() {
var phonenum = document.getElementById("phonenum").value;
var phoneinfo = document.getElementById("phoneinfo");
if (phonenum.length == null || phonenum == "") {
phoneinfo.innerHTML = "";
return true;
} else if (phonenum.search("^[0-9]+(\\-[0-9]+)*?$") == -1
|| phonenum.length > 20) {
phoneinfo.innerHTML = "";
phoneinfo.innerHTML = "<fmt:bundle basename='messages'><fmt:message key='js.phonenum.info'></fmt:message></fmt:bundle>";
return false;
}
phoneinfo.innerHTML = "";
phoneinfo.innerHTML = "<img src='../img/dui.jpg'>";
return true;
}

function checkShopname() {
var shopname = document.getElementById("shopname").value;
var shopnameinfo = document.getElementById("shopnameinfo");
if (shopname.trim() == null || "" == shopname.trim()) {
shopnameinfo.innerHTML = "";
shopnameinfo.innerHTML = "<fmt:bundle basename='messages'><fmt:message key='js.shopname*.info'></fmt:message></fmt:bundle>";
return false;
} else if (shopname.trim().length > 20) {
shopnameinfo.innerHTML = "";
shopnameinfo.innerHTML = "<fmt:bundle basename='messages'><fmt:message key='js.shopname.info'></fmt:message></fmt:bundle>";
return false;
} else {
document.getElementById("shopname").value = shopname.trim();
shopnameinfo.innerHTML = "";
shopnameinfo.innerHTML = "<img src='../img/dui.jpg'>";
}
return true;
}

function checkEmail() {
var email = document.getElementById("email").value;
var emailinfo = document.getElementById("emailinfo");
//对电子邮件的验证
//var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (email.search(/^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+\.(?:com|cn)$/)!= -1) {
emailinfo.innerHTML = "";
emailinfo.innerHTML = "<img src='/trlol/img/dui.jpg'>";
return true;
}else{
emailinfo.innerHTML = "";
emailinfo.innerHTML = "<fmt:bundle basename='messages'><fmt:message key='js.emailnum.info'></fmt:message></fmt:bundle>";
return false;
}

}

上一篇:用css控制表格的内容,使其在固定宽度后换行。


下一篇:cout输出小问题