jquery post后台检查密码

 

 

//检查输入的当前密码是否正确
function checkPassword() {
    var password = $("#OldPassword").val();
    if (password == "" || !password || password == null || password.length < 6) {//密码为空,直接返回
        $("#OldPasswordMsg").html("<font color='Red'>请您输入当前密码</font>").removeClass("checked"); ;
        passwordArray[0] = false;
        return;
    }
    var url = "/User/CheckPassword";
    var data = { password: password };
    $.post(url, data, function (backData, textStatus, xhr) {
        var data = eval("(" + xhr.responseText + ")");//后台返回是json
        if (data) {
            $("#OldPasswordMsg").html("&nbsp;&nbsp;&nbsp;").addClass("checked");
            passwordArray[0] = true;
            return;
        } else {
            $("#OldPasswordMsg").removeClass("checked");
            $("#OldPasswordMsg").html("<font color='Red'>输入的当前密码不正确</font>").removeClass("checked");
            passwordArray[0] = false;
            return;
        }
    }); //end of post
}

你可能感兴趣的:(js,jquery)