日期:2014-05-20 浏览次数:20597 次
function registe(){ if(checkusername()&&checkpassword()&&checksex()&&checkage()){ document.reg.action="showinfo.jsp"; document.reg.submit(); }else if(checkusername()==false){ alert("用户名输入有误"); document.reg.reset(); }else if(checkpassword()==false){ alert("密码输入有误"); document.reg.reset(); }else if(checksex()==false){ alert("性别必须选择"); document.reg.reset(); }else if(checkage()==false){ alert("年龄输入有误"); document.reg.reset(); }else if(checkaddress()==false){ alert("地址是必须选择地"); document.reg.reset(); } } function checkusername(){ var username=document.getElementById("username").value; var reg=/^[a-zA-Z][a-zA-Z0-9_]{6,10}$/; var result=reg.test(username); if(result){ return true; } return false; } function checkpassword(){ var password=document.getElementById("password").value; if(password.length>6&&password.length<10){ return true; } return false; } function checkpasswordequals(){ var password=document.getElementById("password").value; var repassword=document.getElementById("repassword").value; if(password==repassword){ return true; }else{ alert("两次输入密码不一致"); document.getElementById("password").value=""; document.getElementById("repassword").value=""; document.getElementById("password").focus(); } } function checksex(){ var sex=document.getElementsByName("sex"); var sex1=document.getElementsByName("sex").value; alert(sex1); var num=0; for(var i=0;i<sex.length;i++){ if(sex[i].checked){ num=num+1; } } if(num==0){ return false; }else{ return true; } } function checkage(){ var age=document.getElementById("age").value ; if(parseInt(age)>0&&parseInt(age)<150){ return true; } return false; } function checkaddress(){ var add1=document.getElementById("province").value; var add2=document.getElementById("city").value; if((add1==0)||(add2==1)){ return false; } return true; }