![]() |
#2
dzt00012011-09-23 10:58
|
<form name="reg" method="post" onSubmit="return checkForm1();" action="yp.asp?action=add">
为什么表单提交的时候不检查文本框的内容呢。只能检测到名字是否为空其他的都检查不出来就成功提交到数据库了。
<SCRIPT language=JavaScript>
function checkForm()
{
if (document.reg.name.value.length ==""){
alert ("提示:\n\n请输入您的真实姓名!");
document.reg.name.focus();
return false;
}
if (document.reg.name.value.length < 2 || document.reg.name.value.length > 8){
alert ("提示:\n\n姓名必须在2-8字之间!");
document.reg.name.focus();
return false;
}
if (document.reg.h_province.value=='请选择')
{
alert ("提示:\n\n请选择您目前所在地!")
document.reg.x_city.focus();
return false;
}
if (document.reg.Mobile.value=='')
{
alert ("提示:\n\n请输入您的手机号码!")
document.reg.Mobile.focus();
return false;
}
return true;
}
</SCRIPT>