﻿function UserLogin() {
    var username = $('#txtUserName').val();

    var userpass = $('#txtUserPass').val();

    //注册页左边登陆用户名
    if (username.length == 0) {
        alert('用户名不能为空！');
        return;
    }
    //注册页左边登陆用户密码
    if (userpass.length == 0) {
        alert('密码不能为空！');
        return;
    }

    if (username.length < 4 || userpass.length < 4) {
        alert('用户名或密码错误！');
        return;
    }

    $.post('/Ajax/UserLogin.aspx', { txtUserName: username, txtUserPass: userpass },
              function(data, textStatus) {
                  // data 可以是 xmlDoc, jsonObj, html, text, 等等.
                  if (data == 'True') {
                      window.location.href = '/User';
                  }
                  else {
                      alert('用户名或密码错误！');
                  }
              }, "text");
}