表单验证,(为何不能正常运行)?
qfljm 2004-01-13 01:05:13 <SCRIPT LANGUAGE="JavaScript">
window.name='TestIframe';
function CheckForm(theForm){
if (theForm.UserName.value==''){alert("请输入用户名!");theForm.UserName.focus();return false;}
if (theForm.Pass.value==''){alert("请输入密码!");theForm.Pass.focus();return false;}
return true;
}
</SCRIPT>
<form name="form1" method="post" action="" onsubmit="return CheckForm(this)" target="TestIframe">
<input name="UserName" type="text" size="30" maxlength="30">
<input name="Pass" type="password" size="30" maxlength="30">
<input type="button" name="Submit" value="登 录" onClick="form.submit();"class="BUTT">
</form>
================================
代码如上:
我想在提交表单时验证用户名和密码是否为空,
条件是按钮类型必须为 type="button"