使用layer

来源:互联网 发布:新浪php笔试题 编辑:程序博客网 时间:2024/05/29 09:29
<script type="text/javascript" src="static/js/jquery-1.8.3.min.js"></script>
<script src="static/js/layer/layer.js"></script>

<script type="text/javascript">  


var temp = "${PWSimple}";
if(temp == "true"){
layer.open({
        type: 1,
        closeBtn: false,
        shift: 7,
        resize: false,
        title : "初始密码登录,请修改后重新登录!",
        shadeClose: false,
        content: "<div style='width:350px;height:150px;'><div style='width:300px;margin-left: 3%;margin-bottom:20px;margin-top:10px;' class='form-group has-feedback'>   新密码:<input id='newPassword' class='form-control' maxlength='18' type='password' name='newPassword' value=''/></div>" +
        "<div style='width:300px;margin-left: 3%;margin-bottom:20px;' class='form-group has-feedback'>重新输入密码:<input id='secondPassword' maxlength='18' class='form-control' type='password' name='secondPassword' value=''/></div>"+
        "<div style='width:300px;margin-bottom:20px;'><ul class='f_ul' style='float:right;'><li><input class='input_yes' id='smt' style='width:65px;' type='submit' onclick='return layoutSave();' value='确定' /></li><li><input class='input_no' onclick='layoutClose();' style='width:65px;' type='button' value='取消' /></li></ul></div></div>"
    });
}
    
    
function layoutClose(){
layer.close(layer.index);
}


function layoutSave(){
var newPassword = $("#newPassword").val();
var secondPassword = $("#secondPassword").val();
if(newPassword!=secondPassword){
alert("两次密码输入不一致!");
$("#secondPassword").val("");
return false;
}
$.ajax({
url: '/account/user/updatePassword',
type: 'post',
data: {"password":secondPassword,"company":'${company}'},
dataType: 'text',
success: function(data) { 
if(data == "success") {
alert("修改成功!");
window.location.href = "/login";
} else {
alert("修改失败!");

$(".loading").hide();
}
}); 
}


</script>

附件 layer所需js文件static_js.zip

注:有时会报错,多半是因为文件冲突,把js和jquery文件引用放到前面


原创粉丝点击