欢迎各位兄弟 发布技术文章
这里的技术是共享的
<SCRIPT language=JavaScript> function checkForm(){ |
var user=document.getElementById("username"); |
var pwd=document.getElementById("password"); |
if(user.value==""){ |
alert('用户名不允许为空'); |
user.focus(); |
return false; |
} |
if(pwd.value==""){ |
alert('密码不允许为空'); |
pwd.focus(); |
return false; |
} |
document.forms[0].submit(); |
//window.location.href="index.php"; |
} |
</SCRIPT> |
<FORM name=loginform action="index.php" method="post" > <TABLE cellSpacing=0 cellPadding=2 width="50%" border=0> | |
<TBODY valign="middle"> | |
<TR> | |
<TD class=c92 width="24%">用户名</TD> | |
<TD width="76%"><INPUT class=input size=16 id="username" name='userName' value="" | |
onKeyUp="if(event.keyCode==13) document.getElementById('password').focus();" style="width:106"> </TD></TR> | |
<TR> | |
<TD class=c92 width="24%">密 码</TD> | |
<TD width="76%"><INPUT class=input type=password size=16 id="password" name="password" | |
onKeyDown="if(event.keyCode==13) return checkForm()" value="" style="width:106"></TD></TR> | |
<TR> | |
<TD width="24%"> </TD> | |
<TD width="76%"><input type="hidden" name="submitted" value="submitted"> | |
<DIV align=left> | |
<IMG style="CURSOR: hand" onClick="return checkForm()" src="./images/images/login.png" border=0 > | |
| |
<IMG style="CURSOR: hand" src="./images/images/regist.png" border=0 onclick=location.href='./register.php';> | |
</DIV></TD></TR></TBODY></TABLE></FORM> |
input 回车键提交与不提交表单的解决方法