﻿$(document).ready(
        function() {
            $("#ibtLogin").click(function() { return CheckPostUserLogin(); });
            $("#ibtLogin1").click(function() { return CheckPostUserLogin1(); });
            $("#UcLogin1_ibtLogin1").click(function() { return CheckPostUserLogin2(); });
            $("#ibtFind").click(function() { return CheckFindPwd(); });
})
function CheckFindPwd(){
    if ($("#txtUserName").val() == "") {
        alert("请输入用户名.");
        $("#txtUserName").focus();
        return false;
    }
    if ($("#txtEmail").val() == "") {
        alert("请输入邮箱.");
        $("#txtEmail").focus();
        return false;
    }
    return true;
}
function CheckPostUserLogin(){
    if ($("#txtUserName").val() == "") {
        alert("请输入用户名.");
        $("#txtUserName").focus();
        return false;
    }
    if ($("#txtPassword").val() == "") {
        alert("请输入登录密码.");
        $("#txtPassword").focus();
        return false;
    }
    if ($("#txtValidate").val() == "") {
        alert("请输入验证码.");
        $("#txtValidate").focus();
        return false;
    }
    return true;
}


function CheckPostUserLogin1(){
    if ($("#txtUserName1").val() == "") {
        alert("请输入用户名.");
        $("#txtUserName1").focus();
        return false;
    }
    if ($("#txtPassword1").val() == "") {
        alert("请输入登录密码.");
        $("#txtPassword1").focus();
        return false;
    }
    if ($("#txtValidate1").val() == "") {
        alert("请输入验证码.");
        $("#txtValidate1").focus();
        return false;
    }
    return true;
}

function CheckPostUserLogin2(){
    if ($("#UcLogin1_txtUserName").val() == "") {
        alert("请输入用户名.");
        $("#UcLogin1_txtUserName").focus();
        return false;
    }
    if ($("#UcLogin1_txtPassword").val() == "") {
        alert("请输入登录密码.");
        $("#UcLogin1_txtPassword").focus();
        return false;
    }
    if ($("#UcLogin1_txtValidate").val() == "") {
        alert("请输入验证码.");
        $("#UcLogin1_txtValidate").focus();
        return false;
    }
    return true;
}

function PostUserLoginGo(){
    $.post("/Resources/UserLog.aspx", { Action: "post",
        username: $("#txtUserName").val(),
        pwd: $("#txtPwd").val(),
        codes: $("#txtcode").val(),
        strurl: $("#dbUrl").val()
    },
     function (data,textStatus){
        var stringArray = data.result.split("|");
         if (stringArray[0] == "success") {
            if(stringArray[1]==""){
                window.location.href = "/Users/UserCenter.aspx";
             }else{
                window.location.href = stringArray[1];
             }
         }
         else if (stringArray[0] == "fail") {
             alert("用户名或密码验证失败，请重新登录.");
         }
         else if (stringArray[0] == "locks") {
             alert("您所登录的帐号已被管理员禁用.");
         }
         else if (stringArray[0] == "rcoderr") {
             $("#txtcode").focus();
             alert("验证码输入错误");
         }
         else {
             alert(stringArray[0]);
         }
     }, "json");
}

