function check() { /* if(checkspace(document.userinfo.pro_name.value)) { document.userinfo.pro_name.focus(); alert("留言标题不能为空"); return false; }*/ if(checkspace(document.userinfo.contact.value)) { document.userinfo.contact.focus(); alert("联系人不能为空!"); return false; } if(checkspace(document.userinfo.phone.value)) { document.userinfo.phone.focus(); alert("手机不能为空!"); return false; } /* if(document.userinfo.email.value.length!=0) { if (document.userinfo.email.value.charAt(0)=="." || document.userinfo.email.value.charAt(0)=="@"|| document.userinfo.email.value.indexOf('@', 0) == -1 || document.userinfo.email.value.indexOf('.', 0) == -1 || document.userinfo.email.value.lastIndexOf("@")==document.userinfo.email.value.length-1 || document.userinfo.email.value.lastIndexOf(".")==document.userinfo.email.value.length-1) { alert("邮箱格式不对!"); document.userinfo.email.focus(); return false; } } else { alert("邮箱不能为空!"); document.userinfo.email.focus(); return false; } */ /* if(checkspace(document.userinfo.address.value)) { document.userinfo.address.focus(); alert("地址不能为空!"); return false; }*/ if(checkspace(document.userinfo.content.value)) { document.userinfo.content.focus(); alert("留言内容不能为空!"); return false; } /* if(checkspace(document.userinfo.validate.value)) { document.userinfo.validate.focus(); alert("验证码不能为空!"); return false; }*/ } function checkspace(checkstr) { var str = ''; for(i = 0; i < checkstr.length; i++) { str = str + ' '; } return (str == checkstr); } function regInput(obj, reg, inputStr) { var docSel = document.selection.createRange() if (docSel.parentElement().tagName != "INPUT") return false oSel = docSel.duplicate() oSel.text = "" var srcRange = obj.createTextRange() oSel.setEndPoint("StartToStart", srcRange) var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length) return reg.test(str) } function checkRadio(e){//判断是否未被选择 e为 radio的 name var radios = document.getElementsByName(e); for ( var i = 0; i < radios.length; i++) { if (radios[i].checked==true) { i++; return true; //alert("你选中的是第"+i+"个单选框。值为:"+radios[--i].value); } } radios[0].focus(); return false; }