<%@taglib prefix="s" uri="/struts-tags" %> /* 用到了struts,注意引用该标签在jsp界面*/
<body>
<s:form action="confirmMofifyPassword.action" method="get">
<s:password name="companyPassword" label="密码"></s:password>
<s:password name="newpassword" label="新密码" id="newpassword"></s:password>
<s:password name="confirmNewPassword" label="确认新密码" id="confirmNewPassword" ></s:password>
<span id="tishi"></span>
<s:submit value="修改" οnclick="return validate()">
</s:submit>
</s:form>
<script type="text/javascript">
function validate(){
var word1= document.getElementById("newpassword").value;
var word2 = document.getElementById("confirmNewPassword").value;
if(word1 != word2){
window.alert("两次输入的新密码不一致!");
confirmNewPassword.focus();
return false;
}
return true;
}
</script>
</body>
面试 js验证 两次密码是否一致(代码)
最新推荐文章于 2022-11-09 22:56:06 发布