//去除字符串两端空格,用法是string.Trim()
String.prototype.Trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, "");
}
function CheckInput()
{
//验证名称
document.Form1.AddMessage1_MessageTitle.value == document.Form1.AddMessage1_MessageTitle.value.Trim();
if(document.Form1.AddMessage1_MessageTitle.value == "")
{
alert("请输入留言标题");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_MessageTitle.focus();
return false;
}
//验证留言内容
document.Form1.AddMessage1_Content.value == document.Form1.AddMessage1_Content.value.Trim();
if(document.Form1.AddMessage1_Content.value == "")
{
alert("请输入留言内容");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Content.focus();
return false;
}
//验证输入长度
if(document.Form1.AddMessage1_Content.value.length > 1000)
{
alert("您输入的项目详细介绍超长,最多只能输入1000字");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Content.focus();
return false;
}
//验证留言人姓名
document.Form1.AddMessage1_LeaveMan.value == document.Form1.AddMessage1_LeaveMan.value.Trim();
if(document.Form1.AddMessage1_LeaveMan.value == "")
{
alert("请输入您的姓名");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_LeaveMan.focus();
return false;
}
//验证手机号码
document.Form1.AddMessage1_Mobile.value == document.Form1.AddMessage1_Mobile.value.Trim();
/*if(document.Form1.AddMessage1_MsgMobile.value == "")
{
alert("请输入手机号码");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_MsgMobile.focus();
return false;
}*/
//验证手机号码有效性
/*rege=/^13/d{9}$/;
if (!rege.test(document.Form1.AddMessage1_MsgMobile.value))
{
alert("手机号码不合法");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_MsgMobile.focus();
return false;
}
*/
//电话号码
document.Form1.AddMessage1_Phone.value == document.Form1.AddMessage1_Phone.value.Trim();
if(document.Form1.AddMessage1_Phone.value == "")
{
alert("请输入您的电话");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Phone.focus();
return false;
}else
{
if(!document.Form1.AddMessage1_Phone.value.length>7)
{
alert("您输入的电话位数不对!");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Phone.focus();
return false;
}
}
//联系地址
document.Form1.AddMessage1_ContactAddress.value = document.Form1.AddMessage1_ContactAddress.value.Trim();
if(document.Form1.AddMessage1_ContactAddress.value == "")
{
alert("请输入联系地址");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_ContactAddress.focus();
return false;
}
//邮编
document.Form1.AddMessage1_Postcode.value = document.Form1.AddMessage1_Postcode.value.Trim();
if(document.Form1.AddMessage1_Postcode.value == "")
{
alert("请输入邮编");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Postcode.focus();
return false;
}
//QQ
document.Form1.AddMessage1_QQ.value = document.Form1.AddMessage1_QQ.value.Trim();
//MSN
document.Form1.AddMessage1_MSN.value = document.Form1.AddMessage1_MSN.value.Trim();
if(document.Form1.AddMessage1_MSN.value == "")
{
/*alert("请输入MSN地址");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_MsgMSN.focus();
return false;*/
}
else
{
rege=/^([a-zA-Z0-9]+[_|/-|/.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|/-|/.]?)*[a-zA-Z0-9]+/.[a-zA-Z]{2,3}$/;
/*if (!rege.test(document.Form1.MSN.value))
{
alert("MSN地址不合法");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.MSN.focus();
return false;
}*/
}
//Email
document.Form1.AddMessage1_Email.value = document.Form1.AddMessage1_Email.value.Trim();
if(document.Form1.AddMessage1_Email.value == "")
{
/*alert("请输入E_mail地址");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Email.focus();
return false;*/
}
else
{
rege=/^([a-zA-Z0-9]+[_|/-|/.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|/-|/.]?)*[a-zA-Z0-9]+/.[a-zA-Z]{2,3}$/;
if (!rege.test(document.Form1.AddMessage1_Email.value))
{
alert("Email地址不合法");
event.cancelBubble=true;
event.returnValue=false;
document.Form1.AddMessage1_Email.focus();
return false;
}
}
}