jsp如何验证用户信息
1、首先写一个form表单,里面的信息如下:<form method="post" id="form&鳎溻趄酃quot; action="xxx" onsubmi="return check_form()">用户名字:<input type="text" name="username" value=""><br>用户密码:<input type="password" name="password1" value=""><br>再次确认密码:<input type="text" name="password2" value=""><br>用户手机号:<input type="text" name="tel" value=""><br>用户身份证:<input type="text" name="idno" value=""><br>用户邮箱:<input type="text" name="mail" value=""><br><input type="submit" value="提交"><input type="reset" value="重置"></form>

3、判断身份证格式是否正确(用到了js里面的正则表达式)<script>functioncheck_form(){//获得表单的id var f=document.getElementById("form");//判断身份证的格式if(!/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(f.idno.value)){ alert("身份证号格式错误"); return false; }}</script>

5、//判断用户两次输入的密码是否一致<script>functioncheck_form(){//获得表单的id var f=document.getElementById("form");//判断两次输入的密码是否一致if(f.password1.value!=f.password2.value){ alert("两次输入的密码不一样,请重新输入!"); return false; }}</script>
