$(function () {
	$('#UserName').focus().blur(checkName);
	$('#Password').blur(checkPassword);
});

function checkName() {
	var name = $('#UserName').val();
	if (name == null || name == "") {
		//提示错误
		$('#count-msg').html("用户名不能为空");
		return false;
	}
	var reg = /^\w{3,10}$/;
	if (!reg.test(name)) {
		$('#count-msg').html("输入3-10个字母或数字或下划线");
		return false;
	}
	$('#count-msg').empty();
	return true;
}

function checkPassword() {
	var password = $('#password').val();
	if (password == null || password == "") {
		//提示错误
		$('#password-msg').html("密码不能为空");
		return false;
	}
	var reg = /^\w{3,10}$/;
	if (!reg.test(password)) {
		$('#password-msg').html("输入3-10个字母或数字或下划线");
		return false;
	}
	$('#password-msg').empty();
	return true;
}


function logins() {
	var username = $("#UserName").val();
	var pwd = $("#Password").val();

	if (username === '' || pwd === '') {
		return;
	}

	$.ajax({
		url: "/admin/Login",
		type: "post",
		data: "UserName=" + username + "&Password=" + pwd,
		success: function (ret) {
			if (ret.state === -1) {
				alert(ret.mess);
			} else {
				window.location.href = "/Admin/Index";
			}
		}
	});
}