js的Ajax验证
var http_request=false;
function createRequest()//Ajax验证
{
try//IE
{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
http_request = false;
}
}
if (!http_request && typeof XMLHttpRequest != 'undefined') //FireFox
{
http_request = new XMLHttpRequest();
}
}
function callserver()
{
createRequest();
var OstrText=document.getElementById("UserRegister1_UName").value;
var TstrText = jsTrim(OstrText);//查找检查
var strText = trim(TstrText);
if(strText==""||strText==null){
var obj=document.getElementById("reg_UName");
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>账号不能为空。';
return false;
}
else{
if(strText<6)
{
var obj=document.getElementById("reg_UName");
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>账号至少6位。';
return false;
}
else
{
var url="registeryz.aspx?strtxt="+escape(strText);// 传到另一页面查询数据库
http_request.onreadystatechange=updatepage;
http_request.open("GET",url,true);
http_request.send(null);
}
}
}
function updatepage()
{
var obj=document.getElementById("reg_UName");
if(http_request.readyState == 4)
{
if(http_request.status==200)
{
var response=http_request.responseText;
if(response.indexOf("regok")!=-1)
{
//验证通过
obj.className="Right";
obj.innerHTML="<img src=../images/check_right.gif>";
return true;
}
else
{
//验证未通过
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>该账号已经被注册。';
return false;
}
}
}
else
{ //异步传输失败
obj.className="Error"
obj.innerHTML='<img src=../images/check_error.gif>该会员未能检测,可以尝试注册。';
return false;
}
}
//检查获取到的值
function jsTrim(str){
str += "";
while ((str.charAt(0) == ' ') || (str.charAt(0) == '???') || (escape(str.charAt(0)) == '%u3000'))
str = str.substring(1, str.length);
while ((str.charAt(str.length - 1) == ' ') || (str.charAt(str.length - 1) == '???') || (escape(str.charAt(str.length - 1)) == '%u3000'))
str = str.substring(0, str.length - 1);
return str;
}
function trim(inputString){
if (typeof inputString != "string") {
return inputString;
}
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") {
//检查字符串开始部分的空格
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length - 1, retValue.length);
while (ch == " ") {
//检查字符串结束部分的空格
retValue = retValue.substring(0, retValue.length - 1);
ch = retValue.substring(retValue.length - 1, retValue.length);
}
while (retValue.indexOf(" ") != -1) {
//将文字中间多个相连的空格变为一个空格
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ") + 1, retValue.length);
}
return retValue;
}
function checkpwd()
{
var Fpwd = document.getElementById("reg_PassWord");
var OpwdText = document.getElementById("UserRegister1_PassWord").value;
var TpwdText = jsTrim(OpwdText);
var pwdText = trim(TpwdText);
if(pwdText==""||pwdText==null)
{
Fpwd.className="Error";
Fpwd.innerHTML='<img src=../images/check_error.gif>密码不能为空。';
return false;
}
else
{
if(pwdText.length<6)
{
Fpwd.className="Error";
Fpwd.innerHTML='<img src=../images/check_error.gif>密码至少6位。';
return false;
}
else
{
Fpwd.className="Right";
Fpwd.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
}
function Scheckpwd()
{
var Spwd = document.getElementById("reg_SPassWord");
var SOpwdText = document.getElementById("UserRegister1_SPassWord").value;
var FOpwdText = document.getElementById("UserRegister1_PassWord").value;
var TOpwdText = jsTrim(SOpwdText);
var SpwdText = trim(TOpwdText);
var TFpwdText = jsTrim(FOpwdText);
var FpwdText = trim(TFpwdText);
if(SpwdText==""||SpwdText==null)
{
Spwd.className="Error";
Spwd.innerHTML='<img src=../images/check_error.gif>请在输入一次密码。';
return false;
}
else
{
if(SpwdText!=FpwdText)
{
Spwd.className="Error";
Spwd.innerHTML='<img src=../images/check_error.gif>两次输入的密码不相同。';
return false;
}
else
{
Spwd.className="Right";
Spwd.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
}
function checkEmail()
{
var email = document.getElementById("reg_Email");
var OEmailText = document.getElementById("UserRegister1_Email").value;
var TEmailText = jsTrim(OEmailText);
var EmailText = trim(TEmailText);
var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (!re.test(EmailText))
{
email.className="Error";
email.innerHTML='<img src=../images/check_error.gif>邮件格式不准确。';
return false;
}
else
{
email.className="Right";
email.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function checkMobilePhone()
{
var MobilePhone = document.getElementById("reg_MobilePhone");
var OMobilePhoneText = document.getElementById("UserRegister1_MobilePhone").value;
var TMobilePhoneText = jsTrim(OMobilePhoneText);
var MobilePhoneText = trim(TMobilePhoneText);
var myreg = /^(((13[0-9]{1})|159|(15[0-9]{1}))+\d{8})$/;
if(!myreg.test(MobilePhoneText))
{
MobilePhone.className="Error";
MobilePhone.innerHTML='<img src=../images/check_error.gif>手机号码不准确。';
return false;
}
else
{
MobilePhone.className="Right";
MobilePhone.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function checkTName()
{
var TName = document.getElementById("reg_TName");
var OTNameText = document.getElementById("UserRegister1_TName").value;
var TTNameText = jsTrim(OTNameText);
var TNameText = trim(TTNameText);
if(TTNameText==""||TTNameText==null)
{
TName.className="Error";
TName.innerHTML='<img src=../images/check_error.gif>姓名不能为空。';
return false;
}
else
{
var txt=new RegExp("[ ,\\`,\\~,\\!,\\¥,\\@,\#,\\$,\\%,\\^,\\+,\\*,\\&,\\\\,\\/,\\?,\\|,\\:,\\.,\\<,\\>,\\{,\\},\\(,\\),\\',\\;,\\=,\"]");
if(!txt.test(TTNameText))
{
TName.className="Right";
TName.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
TName.className="Error";
TName.innerHTML='<img src=../images/check_error.gif>姓名中不能包括特殊符号。';
return false;
}
}
}
function checkCertifcateCode()
{
var CertifcateCode = document.getElementById("reg_CertifcateCode"); //身份证验证
var OCertifcateCode = document.getElementById("UserRegister1_CertifcateCode").value;
var TCertifcateCodeText = jsTrim(OCertifcateCode);
var CertifcateCodeText = trim(TCertifcateCodeText);
var Errors=new Array("验证通过。","身份证号码位数不对。","身份证号码出生日期超出范围或含有非法字符。","身份证号码校验错误。","身份证地区非法。");
var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
var retflag=false;
var idcard,Y,JYM;
var S,M;
var idcard_array = new Array();
idcard_array = CertifcateCodeText.split("");
//地区检验
if(area[parseInt(CertifcateCodeText.substr(0,2))]==null)
{
CertifcateCode.className="Error";
CertifcateCode.innerHTML= "<img src=../images/check_error.gif>"+Errors[4];
return false;
}
else
{
//身份号码位数及格式检验
switch(CertifcateCodeText.length)
{
case 15:
//15位身份号码检测
if ((parseInt(CertifcateCodeText.substr(6,2))+1900)%4==0||((parseInt(CertifcateCodeText.substr(6,2))+1900)%100==0&&(parseInt(CertifcateCodeText.substr(6,2))+1900)%4==0))
{
//测试出生日期的合法性
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;
}
else
{
//测试出生日期的合法性
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;
}
if(ereg.test(CertifcateCodeText))
{
CertifcateCode.className="Right";
CertifcateCode.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
CertifcateCode.className="Error";
CertifcateCode.innerHTML= "<img src=../images/check_error.gif>"+Errors[2];
return false;
}
break;
case 18:
//18位身份号码检测
//出生日期的合法性检查
//闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
if ( parseInt(CertifcateCodeText.substr(6,4)) % 4 == 0 || (parseInt(CertifcateCodeText.substr(6,4)) % 100 == 0 && parseInt(CertifcateCodeText.substr(6,4))%4 == 0 ))
{
//闰年出生日期的合法性正则表达式
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;
}
else
{
//平年出生日期的合法性正则表达式
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;
}
if(ereg.test(CertifcateCodeText))
{
//计算校验位
S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7+ (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9+ (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10+ (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5+ (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8+ (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4+ (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2+ parseInt(idcard_array[7]) * 1+ parseInt(idcard_array[8]) * 6+ parseInt(idcard_array[9]) * 3 ;
Y = S % 11;
M = "F";
JYM = "10X98765432";
//判断校验位
M = JYM.substr(Y,1);
if(M == idcard_array[17])
{
//检测ID的校验位
CertifcateCode.className="Right";
CertifcateCode.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
CertifcateCode.className="Error";
CertifcateCode.innerHTML= "<img src=../images/check_error.gif>"+Errors[3];
return false;
}
}
else
{
CertifcateCode.className="Error";
CertifcateCode.innerHTML= "<img src=../images/check_error.gif>"+Errors[2];
return false;
}
break;
default:
CertifcateCode.className="Error";
CertifcateCode.innerHTML= "<img src=../images/check_error.gif>"+Errors[1];
return false;
break;
}
}
}
function submitbtn()
{
if(callserver() == false)
{
alert("请重新输入账号!");
return false;
}
if(updatepage() == false)
{
alert("用户名已经存在,请重新填写!");
return false;
}
if(checkpwd() == false)
{
alert("请输入密码!");
return false;
}
if(Scheckpwd() == false)
{
alert("两次密码不相同!");
return false;
}
if(checkEmail() == false)
{
alert("请重新输入邮箱地址!");
return false;
}
if(checkMobilePhone() == false)
{
alert("请重新输入电话号码!");
return false;
}
if(checkTName() == false)
{
alert("请输入姓名!");
return false;
}
if(checkCertifcateCode() == false)
{
alert("请重新输入身份证身份证!");
return false;
}
if(yzmcallserver() == false)
{
alert("请重新输入验证码!");
return false;
}
}
function yzmcallserver()
{
createRequest();
var Oyzm=document.getElementById("UserRegister1_yzm").value;
var Tyzm = jsTrim(Oyzm);
var yzmText = trim(Tyzm);
if(yzmText==""||yzmText==null)
{
var yzm=document.getElementById("reg_yzm");
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写验证码。';
return false;
}
else
{
var url="yzmregisteryz.aspx?myyzm="+escape(yzmText);
http_request.onreadystatechange=yzmupdatepage;
http_request.open("GET",url,true);
http_request.send(null);
}
}
function yzmupdatepage()
{
var obj=document.getElementById("reg_yzm");
if(http_request.readyState == 4)
{
if(http_request.status==200)
{
var response=http_request.responseText;
if(response.indexOf("regokyzm")!=-1)
{
//验证通过
obj.className="Right";
obj.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
//验证未通过
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>验证码输入错误。';
return false;
}
}
}
else
{ //异步传输失败
obj.className="Error"
obj.innerHTML='<img src=../images/check_error.gif>未能检测,请重新输入。';
return false;
}
}
function yzinsertcallserver()
{
createRequest();
var OStadium=document.getElementById("Stadium").value;//一、从前台获取场馆名即获取验证值
var TStadium = jsTrim(OStadium);//检验值
var StadiumText = trim(TStadium);//检验值
if(StadiumText==""||StadiumText==null) //二、判断如果为空
{
var yzm=document.getElementById("reg_Stadium");//获取层的ID
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写场馆名。';//三、显示 在层上显示请填写
return false;
}
else
{
var url="yzStadiumName.aspx?yzStadiumName="+escape(StadiumText);//四、否则 不为空把参数传到这个页面根据名称去数据库中查询如果有数据
http_request.onreadystatechange=yzinsertdatepage;//调用方法
http_request.open("GET",url,true);
http_request.send(null);
}
}
function yzinsertdatepage()
{
var obj=document.getElementById("reg_Stadium");//前台隐藏层的ID
if(http_request.readyState == 4)
{
if(http_request.status==200)
{
var response=http_request.responseText;//获取yzStadiumName.aspx页面的内容 如果是regokStadiumName验证通过
if(response.indexOf("regokStadiumName")!=-1)//
{
//验证通过
obj.className="Right";
obj.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
//验证未通过
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>场馆名已经存在,请重新输入。';
return false;
}
}
}
else
{ //异步传输失败
obj.className="Error"
obj.innerHTML='<img src=../images/check_error.gif>未能检测,请重新输入。';
return false;
}
}
function yzaddress()
{
var Addres =document.getElementById("reg_Address");
var OAddress = document.getElementById("Address").value;
var TAddres = jsTrim(OAddress);
var AddresText = trim(TAddres);
if(AddresText==""||AddresText==null)
{
Addres.className="Error";
Addres.innerHTML='<img src=../images/check_error.gif>地址不能为空。';
return false;
}
else
{
Addres.className="Right";
Addres.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function checkphone()
{
var Phone =document.getElementById("reg_Phone");
var OPhone = document.getElementById("Phone").value;
var TPhone = jsTrim(OPhone);
var PhoneText = trim(TPhone);
if(PhoneText==""||PhoneText==null)
{
Phone.className="Error";
Phone.innerHTML='<img src=../images/check_error.gif>座机不能为空。';
return false;
}
else
{
var regtext = new RegExp("[0-9]{3,4}\-[0-9]{7,8}");
if(regtext.test(PhoneText))
{
Phone.className="Right";
Phone.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
Phone.className="Error";
Phone.innerHTML='<img src=../images/check_error.gif>座机格式错误,格式如(012-12345678)';
return false;
}
}
}
function checkAttn()
{
var Attn =document.getElementById("reg_Attn");
var OAttn = document.getElementById("Attn").value;
var TAttn = jsTrim(OAttn);
var AttnText = trim(TAttn);
if(AttnText==""||AttnText==null)
{
Attn.className="Error";
Attn.innerHTML='<img src=../images/check_error.gif>联系人不能为空。';
return false;
}
else
{
Attn.className="Right";
Attn.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function checkStadiumEmail()
{
var email = document.getElementById("reg_Email");
var OEmailText = document.getElementById("Email").value;
var TEmailText = jsTrim(OEmailText);
var EmailText = trim(TEmailText);
var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (!re.test(EmailText))
{
email.className="Error";
email.innerHTML='<img src=../images/check_error.gif>邮件格式不准确。';
return false;
}
else
{
email.className="Right";
email.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function Stadiumsubmitbtn()
{
if(yzinsertcallserver() == false)
{
alert("请输入场馆名称!");
return false;
}
if(yzinsertdatepage() == false)
{
alert("场馆名已经存在,请重新填写!");
return false;
}
if(yzaddress() == false)
{
alert("请输入地址!");
return false;
}
if(checkphone() == false)
{
alert("请输入座机号码!");
return false;
}
if(checkAttn() == false)
{
alert("请输入联系人!");
return false;
}
if(checkStadiumEmail() == false)
{
alert("请输入联系人邮箱!");
return false;
}
}
// function showStadium(id)
// {
// var hfstr=id.substr(21,5);
// var hfsidValue = document.getElementById("MyStadium1_GVStadium_"+hfstr+"_hfsid").value;
// showdlStadium(hfsidValue);
// }
// function closeStadium()
// {
// var mydiv = document.getElementById("showdiv");
// mydiv.style.display="none";
// }
// function showdiv(id)
// {
// var mydiv = document.getElementById(id);
// mydiv.style.display="block";
// }
// function closediv(id)
// {
// var mydiv = document.getElementById(id);
// mydiv.style.display="none";
// }
//
// function showdlStadium(id)
// {
// createRequest();
// if(id!=""||id!=null||id!=0)
// {
// var url="MyStadium.aspx?Stadiumid="+id;
// http_request.onreadystatechange=showdlStadiumdiv;
// http_request.open("GET",url,true);
// http_request.send(null);
// }
// }
// function showdlStadiumdiv()
// {
// var mydiv = document.getElementById("showdiv")
// if(http_request.readyState == 4)
// {
// if(http_request.status==200)
// {
// var response=http_request.responseText;
// if(response.indexOf("Stadiumregok")!=-1)
// {
// mydiv.style.display="block";
// }
// else
// {
// alert('验证未通过');
// //mydiv.style.display="none";
// }
// }
// }
// else
// {
// alert('异步传输失败');
// mydiv.style.display="none";
// }
// }
function yzupdateaddress()
{
var Addres =document.getElementById("reg_Address");
var OAddress = document.getElementById("Address").value;
var TAddres = jsTrim(OAddress);
var AddresText = trim(TAddres);
if(AddresText==""||AddresText==null)
{
Addres.className="Error";
Addres.innerHTML='<img src=../images/check_error.gif>地址不能为空。';
return false;
}
else
{
Addres.className="Right";
Addres.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function updatecheckphone()
{
var Phone =document.getElementById("reg_Phone");
var OPhone = document.getElementById("Phone").value;
var TPhone = jsTrim(OPhone);
var PhoneText = trim(TPhone);
if(PhoneText==""||PhoneText==null)
{
Phone.className="Error";
Phone.innerHTML='<img src=../images/check_error.gif>座机不能为空。';
return false;
}
else
{
var regtext = new RegExp("[0-9]{3,4}\-[0-9]{7,8}");
if(regtext.test(PhoneText))
{
Phone.className="Right";
Phone.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
Phone.className="Error";
Phone.innerHTML='<img src=../images/check_error.gif>座机格式错误,格式如(012-12345678)';
return false;
}
}
}
function checkupdateAttn()
{
var Attn =document.getElementById("reg_Attn");
var OAttn = document.getElementById("Attn").value;
var TAttn = jsTrim(OAttn);
var AttnText = trim(TAttn);
if(AttnText==""||AttnText==null)
{
Attn.className="Error";
Attn.innerHTML='<img src=../images/check_error.gif>联系人不能为空。';
return false;
}
else
{
Attn.className="Right";
Attn.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function updatecheckStadiumEmail()
{
var email = document.getElementById("reg_Email");
var OEmailText = document.getElementById("Email").value;
var TEmailText = jsTrim(OEmailText);
var EmailText = trim(TEmailText);
var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (!re.test(EmailText))
{
email.className="Error";
email.innerHTML='<img src=../images/check_error.gif>邮件格式不准确。';
return false;
}
else
{
email.className="Right";
email.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function yzupdatestadium()
{
var stadium = document.getElementById("reg_Stadium");
var Ostadium = document.getElementById("Stadium").value;
var Tstadium = jsTrim(Ostadium);
var stadiumText = trim(Tstadium);
if(stadiumText==""||stadiumText==null)
{
stadium.className="Error";
stadium.innerHTML='<img src=../images/check_error.gif>场馆名不能为空。';
return false;
}
else
{
stadium.className="Right";
stadium.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function UpdateStadiumsubmitbtn()
{
if(yzupdatestadium() == false)
{
alert("请输入场馆名称!");
return false;
}
if(yzupdateaddress() == false)
{
alert("请输入地址!");
return false;
}
if(updatecheckphone() == false)
{
alert("请输入座机号码!");
return false;
}
if(checkupdateAttn() == false)
{
alert("请输入联系人!");
return false;
}
if(updatecheckStadiumEmail() == false)
{
alert("请输入联系人邮箱!");
return false;
}
}
function yzsportscallserver()
{
createRequest();
var OSportsName=document.getElementById("SportsName").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
var yzm=document.getElementById("reg_SportsName");
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写场地名。';
return false;
}
else
{
var url="yzSportsName.aspx?yzSportsName="+escape(SportsNameText);
http_request.onreadystatechange=yzsports;
http_request.open("GET",url,true);
http_request.send(null);
}
}
function yzsports()
{
var obj=document.getElementById("reg_SportsName");
if(http_request.readyState == 4)
{
if(http_request.status==200)
{
var response=http_request.responseText;//获取yzSportsName.aspx页面的内容如果是regokSportsName验证通过
if(response.indexOf("regokSportsName")!=-1)
{
//验证通过
obj.className="Right";
obj.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
//验证未通过
obj.className="Error";
obj.innerHTML='<img src=../images/check_error.gif>场地名已经存在,请重新输入。';
return false;
}
}
}
else
{ //异步传输失败
obj.className="Error"
obj.innerHTML='<img src=../images/check_error.gif>未能检测,请重新输入。';
return false;
}
}
function yzsz()
{
var yzm=document.getElementById("reg_scounts");
var Oscounts = document.getElementById("scounts").value;
var Tscounts = jsTrim(Oscounts);
var scountsText = trim(Tscounts);
if(scountsText==""||scountsText==null||scountsText==0)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请重新填写场地数量(不能为0)。';
return false;
}
else
{
var sz = new RegExp("^[0-9]");
var szz = new RegExp("/^[0-9]*[1-9][0-9]*$/")
//if(szz.test(scountsText) && scountsText>0)
if(/^[-]?\d+$/.test(scountsText))
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写正整数。';
return false;
}
}
}
function insertsports()
{
if(yzsportscallserver() == false)
{
alert("请输入场地名称!");
return false;
}
if(yzsports() == false)
{
alert("场地名已经存在,请重新填写!");
return false;
}
if(yzaddress() == false)
{
alert("请输入地址!");
return false;
}
if(checkphone() == false)
{
alert("请输入座机号码!");
return false;
}
if(checkAttn() == false)
{
alert("请输入联系人!");
return false;
}
if(checkStadiumEmail() == false)
{
alert("请输入联系人邮箱!");
return false;
}
if(yzsz() == false)
{
alert("请输入场地数量!");
return false;
}
}
function yzupdatesport()
{
var yzm=document.getElementById("reg_SportsName");
var OSportsName=document.getElementById("SportsName").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写场地名。';
return false;
}
else
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function updatesports()
{
if(yzupdatesport() == false)
{
alert("请输入场地名称!");
return false;
}
if(yzaddress() == false)
{
alert("请输入地址!");
return false;
}
if(checkphone() == false)
{
alert("请输入座机号码!");
return false;
}
if(checkAttn() == false)
{
alert("请输入联系人!");
return false;
}
if(checkStadiumEmail() == false)
{
alert("请输入联系人邮箱!");
return false;
}
if(yzsz() == false)
{
alert("请输入场地数量!");
return false;
}
}
function ctitle()
{
var yzm=document.getElementById("reg_title");
var OSportsName=document.getElementById("title").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写标题。';
return false;
}
else
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function cAttendance()
{
var yzm=document.getElementById("reg_Attendance");
var Oscounts = document.getElementById("Attendance").value;
var Tscounts = jsTrim(Oscounts);
var scountsText = trim(Tscounts);
if(scountsText==""||scountsText==null||scountsText==0)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请重新填人数(不能为0)。';
return false;
}
else
{
var sz = new RegExp("^[0-9]");
var szz = new RegExp("/^[0-9]*[1-9][0-9]*$/")
//if(szz.test(scountsText) && scountsText>0)
if(/^[-]?\d+$/.test(scountsText))
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写正整数。';
return false;
}
}
}
function cCost()
{
var yzm=document.getElementById("reg_Cost");
var Oscounts = document.getElementById("Cost").value;
var Tscounts = jsTrim(Oscounts);
var scountsText = trim(Tscounts);
if(scountsText==""||scountsText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写费用(不能为0)。';
return false;
}
else
{
var sz = new RegExp("^[0-9]");
var szz = new RegExp("/^[0-9]*[1-9][0-9]*$/")
//if(szz.test(scountsText) && scountsText>0)
if(/^[-]?\d+$/.test(scountsText))
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
else
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请填写正整数。';
return false;
}
}
}
function cExpireDate()
{
var yzm=document.getElementById("reg_ExpireDate");
var OSportsName=document.getElementById("ExpireDate").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请选择有效期至。';
return false;
}
else
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function cStartTime()
{
var yzm=document.getElementById("reg_StartTime");
var OSportsName=document.getElementById("StartTime").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请选择开始时间。';
return false;
}
else
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function cEndTime()
{
var yzm=document.getElementById("reg_EndTime");
var OSportsName=document.getElementById("EndTime").value;
var TSportsName = jsTrim(OSportsName);
var SportsNameText = trim(TSportsName);
if(SportsNameText==""||SportsNameText==null)
{
yzm.className="Error";
yzm.innerHTML='<img src=../images/check_error.gif>请选择结束时间。';
return false;
}
else
{
yzm.className="Right";
yzm.innerHTML="<img src='../images/check_right.gif'/>";
return true;
}
}
function tjhd()
{
if(ctitle() == false)
{
alert("请输入标题!");
return false;
}
if(cAttendance() == false)
{
alert("请输入人数!");
return false;
}
if(cCost() == false)
{
alert("请输入费用!");
return false;
}
if(cExpireDate() == false)
{
alert("请选择有效期至!");
return false;
}
if(cStartTime() == false)
{
alert("请选择开始时间!");
return false;
}
if(cEndTime() == false)
{
alert("请选择结束时间!");
return false;
}
}