我很菜,但我很努力!
<script language=javascript> function check(theForm) { if (theForm.user.value == "") { alert("请你填写访客姓名!"); theForm.user.focus(); return (false); } var checkname=theForm.user.value if (checkname.length>10) { alert("填写的名字不得超过10汉字!"); theForm.user.focus(); return (false); } if (theForm.oicq.value != "") { var checkoicq = "0123456789"; var checkStr = theForm.oicq.value; if (checkStr.length<5) { alert("填写OICQ必须大于5位数字!"); theForm.oicq.focus(); return (false); } for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkoicq.length; j++) if (ch == checkoicq.charAt(j)) break; if (j == checkoicq.length) { alert("请你填写OICQ号码包含非法字符!"); theForm.oicq.focus(); return (false); break; } } } if (theForm.email.value == "") { alert("请你填写E-Mail!"); theForm.email.focus(); return (false); } if (!check_email(theForm.email.value)) { alert("请你填写Email有错误!"); theForm.email.focus(); return (false); } var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@."; var checkStr = theForm.email.value; var allValid = true; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { alert("请你填写Email包含非法字符!"); theForm.email.focus(); return (false); break; } }
function check_email(address) { if ((address.indexOf ('@') == -1) || (address.indexOf ('.') == -1)) return false; return true; }
if (theForm.msg.value == "") { alert("请你填写留言内容!"); theForm.msg.focus(); return (false); } var checklen=theForm.msg.value if (checklen.length>100) { alert("填写内容不得超过100汉字!"); theForm.msg.focus(); return (false); } }
</script>