当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js验证密码(实例代码)

js验证密码(实例代码)

2018年10月18日  | 移动技术网IT编程  | 我要评论

js验证密码(实例代码)

<html>
  <head>
    <base href="<%=basepath%>">
    
    <title>my jsp 'register.jsp' starting page</title> 
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<!-- 验证两次密码输入是否一致 -->
<script type="text/javascript" language="javascript">
function passwordissame(){
var password=document.userform.password.value;
var repassword=document.userform.repassword.value;
  if(password!="" && repassword!=""){
   if(password==repassword){ 
   managerform.newpasswod.focus(); 
   return true;   }
    }
    window.alert("非法操作"); 
  return false;
}
</script>
  </head>
  
  <body>
    <form name="userform" action="registerdeal.jsp" method="post" onsubmit="return passwordissame()">
    用户名:<input name="name" type="text"/><br/>
    密    码:<input name="password" type="text"/><br/>
    确认密码:<input name="repassword" type="text"/><br/>
    <input type="submit" value="register">
    <input type="reset" value="reset">
    </form>
  </body>
</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网