日期:2014-05-17 浏览次数:20751 次
function userPwds(){ var pass=document.getElementById("upass").value; var upassd=document.getElementById("upassnu"); if(pass==""){ upassd.innerHTML="密码不能为空!"; document.getElementById("upass").focus(); return false; } else{ upassd.innerHTML=""; var regster= /^[A-Za-z0-9]+$/; if(regster.test(pass)==false){ upassd.innerHTML="密码格式输入不正确!"; document.getElementById("upass").focus(); return false; } } } function userName(){ var name=document.getElementById("uname").value; var unamenull=document.getElementById("unamenull"); if(name==""){ unamenull.innerHTML="用户名不能为空!"; document.getElementById("uname").focus(); return false; } else{ unamenull.innerHTML=""; var username= /^[A-Za-z0-9]+$/; if(username.test(name)==false){ unamenull.innerHTML="用户名格式输入不正确!只能字母和数字"; document.getElementById("uname").focus(); return false; } } }
<form action="" method="post" name="myForm" onsubmit="checklogin()"> <table> <tr> <td>用户名:<input type="text" id="uname" name="username" class="size" onblur= "userName()"/></td> </tr> <tr> <td id="unamenull"></td> </tr> <tr> <td>密 码:<input type="password" id="upass" name="pwd" class="size" onblur= "userPwds()" /></td> </tr> <tr> <td id="upassnu"></td> </tr> </table> <input type="button" src="images/sms_btn_login.png" class="but" /> <input type="button" src="images/sms_btn_reg.png" class="but2" /> </form>