<input style="float: right;margin-right: 50px;margin-bottom: 10px;margin-top: 0px;" data-toggle="modal" data-target="#updatePassword" class="btn btn-primary" type="button" value="修改密码" />
<!-- 模态框(Modal) -->
<div class="modal fade" id="updatePassword" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div id="updatePassword" style="margin-top: 15px" > <img alt="update" src="<%=request.getContextPath()%>/resources/image/userMgr/update.png"> <label>密码修改</label></div>
<hr>
<form name="pwd_change_form" action="${pageContext.request.contextPath}/asset/user/updatePassword?userId=${sessionScope.loginUser.userId }" method="post">
<div id="userInfo" class="modal-body">
<table>
<tr>
<td><input type="hidden" name="holdPassword" value =${sessionScope.loginUser.password } /></td>
<td><input type="hidden" name="userName" value =${sessionScope.loginUser.userName } /></td>
</tr>
<tr>
<td>旧 密 码: <input placeholder="密码长度为5~16" minlength="5" maxlength="16" type="password" name="oldPassword" id="oldPassword"/></td>
</tr>
<tr>
<td>新 密 码: <input placeholder="密码长度为5~16" minlength="5" maxlength="16" type="password" name="newPassword" id="newPassword"/></td>
</tr>
<tr>
<td>确认新密码: <input placeholder="密码长度为5~16" minlength="5" maxlength="16" type="password" name="password" id="password"/></td>
</tr>
</table>
</div>
<div class="modal-footer">
<input type="button" data-dismiss="modal" style="width:110px;height:40px; background: url('<%=request.getContextPath()%>/resources/image/userMgr/cancel.png');"/>
<input type="submit" onClick="return checkForm(pwd_change_form)" style="width:110px;height:40px; background: url('<%=request.getContextPath()%>/resources/image/userMgr/save.png');" name="updatePassword" value=""/>
</div>
</form>
</div>
</div>
</div>
在body中写:
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/md5.js" ></script>
<script language="javascript">
function checkForm(form){
if(form.oldPassword.value==""){
alert("请输入的原密码!");
form.oldPassword.focus();
return false;
}
if(md5(form.oldPassword.value)!=form.holdPassword.value){
alert("您输入的原密码不正确,请重新输入!");
form.oldPassword.value="";
form.oldPassword.focus();
return false;
}
if(form.newPassword.value==""){
alert("请输入的新密码!");
form.newPassword.focus();
return false;
}
if(form.password.value==""){
alert("请确认新密码!");
form.password.focus();
return false;
}
if(form.newPassword.value!=form.password.value){
alert("您输入的新密码不一致,请重新输入!");
form.newPassword.value="";
form.password.value="";
form.newPassword.focus();
return false;
}
}
</script>
MD5加密方法参考:
http://www.bootcdn.cn/blueimp-md5/
https://github.com/blueimp/JavaScript-MD5
网友评论