var state = false;
$(document).ready(function(){
$("#txt2UserName").focus();
$("#txt2UserName").keyup(function(){
$.ajax({
//提交數(shù)據(jù)的類型 POST GET
type:"GET",
//提交的網(wǎng)址
url: "reg.aspx",
//提交的數(shù)據(jù)
data:{isAjax:"true",Name:$("#txt2UserName").val()},//$("#txt2UserName").val()
//返回數(shù)據(jù)的格式
datatype: "text",//"xml", "html", "script", "json", "jsonp", "text".
//在請求之前調(diào)用的函數(shù)
//beforeSend:function(){$("#idMessage").html("logining");},
//成功返回之后調(diào)用的函數(shù)
// success:function(data){
// $("#idMessage").html(decodeURI(data));
//} ,
//調(diào)用執(zhí)行后調(diào)用的函數(shù)
complete: function(XMLHttpRequest, textStatus){
//alert(XMLHttpRequest.responseText);
var mes = XMLHttpRequest.responseText;
state =mes=="0";
mes = mes=="0"?("用戶名可以注冊!"):("用戶名已存在不能注冊!");
$("#idMessage").html(mes);
//HideLoading();
},
//調(diào)用出錯執(zhí)行的函數(shù)
error: function(){
//請求出錯處理
}
});
// $("#idMessage").html($(this).val());
})
$("#BtReg").bind("click",
function()
{
var txt2UserName = $("#txt2UserName").val();
var txt2Pwd = $("#txt2Pwd").val();
var txt2APwd = $("#txt2APwd").val();
var txt2Mail = $("#txt2Mail").val();
if(txt2UserName.length<1)
{
$.messager.alert('信息','用戶名不能為空!');
$("#txt2UserName").focus();
return false;
}
else if(txt2Pwd.length<1)
{
$.messager.alert('信息','密碼不能為空!');
$("#txt2Pwd").focus();
return false;
}
else if(txt2APwd.length<1)
{
$.messager.alert('信息','密碼不能為空!');
$("#txt2APwd").focus();
return false;
}
else if(txt2APwd!=txt2Pwd)
{
$.messager.alert('信息','兩次密碼輸入不一致!');
$("#txt2APwd").focus();
return false;
}
else if(txt2Mail.length<1)
{
$.messager.alert('信息','郵箱不能為空!');
$("#txt2Mail").focus();
return false;
}
else if(!state)
{
$.messager.alert('信息','用戶名已存在請重新注冊!');
$("#txt2UserName").focus();
return false;
}
else
{
return true;
}
})
});
// 顯示信息
function showMessage(mes)
{
$(document).ready(function(){
$.messager.alert('信息',mes);
$("#txtUserName").foucs();
})
}