如题所述
<head><script language="java" type="text/javascript">var isDtataOK=false;funtion Submitl_onclick() { return isDtataOK; }funtion onChange(obj){ try { if(obj=="UserName"){ var userObj=docmemt.getElementById(obj); var user=new String(userObj.value); if((user.length>20)//(userObj.value=="")){ alert("用户名不合法:超过20个字符或为空!"); userObj.value=""; isDtataOK=false; } } if(obj=="Password1"){ var pwdObj=docmemt.getElementById(obj); var pwd=new String(pwdObj.value); if((pwd.length>20)//(pwd=="")){ alert("密码不合法:超过20个字符或为空!"); pwdObj.value=""; isDtataOK=false; return; } else{ continue; } } else { break; } } }isDtataOK=true; } } catche(e){ alert("对不起,有错误发生:"e.description); } }</head><body><form id="frmLogin" action="#" method="post"> 账号:<input id="UserName" type=text onchange="pmChange(this.id)"/>账号:<input id="Password1" type=password onchange="pmChange(this.id)"/><input id="Reset1" type="reset" value="重置"><input id="Submit1" type="submit" value="登录" onclick="return Submit1_onclick()"></form></body>
温馨提示:答案为网友推荐,仅供参考