// mailwrite.js //去左空格; function ltrim(s) { return s.replace(/(^\s*)/g, ""); } //去右空格; function rtrim(s) { return s.replace(/(\s*$)/g, ""); } //去左右空格; function trim(s){ //s.replace(/(^\s*)|(\s*$)/g, ""); return rtrim(ltrim(s)); } //检查表单 function checkForm(){ var alertinfo = ""; if(trim(document.writeForm.title.value).length==0){ if(alertinfo.length==0) document.writeForm.title.focus(); alertinfo = alertinfo + "标题 不能为空;\r\n"; //return false; } if(trim(document.writeForm.content.value).length==0){ if(alertinfo.length==0) document.writeForm.content.focus(); alertinfo = alertinfo + "内容 不能为空;\r\n"; //return false; } //验证必填项 var mustfield = document.writeForm.mustfield.value; var iarray = mustfield.split(","); for(i=0;mustfield.length>0 && i0){ alert(alertinfo); return false; } writeForm.submit(); } //验证email function ismail(mail) { return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); } function isphone(phone) { var reg0 = /^13\d{5,9}$/; var reg1 = /^15\d{5,9}$/; var reg2 = /^18\d{5,9}$/; var reg3 = /^0\d{10,11}$/; var b = false; if(reg0.test(phone))b = true; if(reg1.test(phone))b = true; if(reg2.test(phone))b = true; if(reg3.test(phone))b = true; if(phone.length < 11)b = false; return b; }