这个控件主要是用来对输入的文本框是否符合正则表达式进行验证。
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
table
class
="userRegisterTable"
cellpadding
="0"
cellspacing
="0"
>
< tr >< td colspan ="2" align ="center" class ="userRegisterTableHead" > 注册资料 </ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 注册帐号 </ td >< td >
< asp:TextBox ID ="txtLoginName" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanLoginName" ></ span >
< asp:CustomValidator
ID ="CustomValidator1"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtLoginName"
ClientValidationFunction ="ClientValidatorLoginName" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorLoginName(oSrc, args) {
var txt = document.getElementById( ' <%=txtLoginName.ClientID %> ' ).value;
var lbl = document.getElementById( " spanLoginName " );
var lbl_value = _LoginName(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ● < span
class ="userRegisterSpan" > 以字母开头, </ span > 由字母a-z(不区分大小写)、数字0-9、下划线组成 </ span >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ●长度:4-16个字符 </ span >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 密码 </ td >< td >
< asp:TextBox ID ="txtPassword" runat ="server" TextMode ="Password" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPassword" ></ span >
< asp:CustomValidator
ID ="CustomValidator2"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPassword"
ClientValidationFunction ="ClientValidatorPassword" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPassword(oSrc, args) {
var txt = document.getElementById( ' <%=txtPassword.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPassword " );
var lbl_value = _PassWord(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ●密码长度6-16位,字母区分大小写 </ span >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 确认密码 </ td >< td >
< asp:TextBox ID ="txtPasswordAgain" runat ="server" TextMode ="Password" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPasswordAgain" ></ span >
< asp:CustomValidator
ID ="CustomValidator3"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPasswordAgain"
ClientValidationFunction ="ClientValidatorPasswordAgain" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPasswordAgain(oSrc, args) {
var txt1 = document.getElementById( ' <%=txtPassword.ClientID %> ' ).value;
var txt2 = document.getElementById( ' <%=txtPasswordAgain.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPasswordAgain " );
var lbl_value = _PassWordAgain(txt1, txt2);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 电子邮箱 </ td >< td >
< asp:TextBox ID ="txtEmail" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanEmail" ></ span >
< asp:CustomValidator
ID ="CustomValidator4"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtEmail"
ClientValidationFunction ="ClientValidatorEmail" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorEmail(oSrc, args) {
var txt = document.getElementById( ' <%=txtEmail.ClientID %> ' ).value;
var lbl = document.getElementById( " spanEmail " );
var lbl_value = _EmailNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 身份证号 </ td >< td >
< asp:TextBox ID ="txtCardID" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanCardID" ></ span >
< asp:CustomValidator
ID ="CustomValidator5"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtCardID"
ClientValidationFunction ="ClientValidatorCardID" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorCardID(oSrc, args) {
var txt = document.getElementById( ' <%=txtCardID.ClientID %> ' ).value;
var lbl = document.getElementById( " spanCardID " );
var cardID = txt + " ,2,0 " ;
var lbl_value = _ChinaCardNo(cardID);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 真实姓名 </ td >< td >
< asp:TextBox ID ="txtRealName" runat ="server" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanRealName" ></ span >
< asp:CustomValidator
ID ="CustomValidator6"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtRealName"
ClientValidationFunction ="ClientValidatorRealName" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorRealName(oSrc, args) {
var txt = document.getElementById( ' <%=txtRealName.ClientID %> ' ).value;
var lbl = document.getElementById( " spanRealName " );
var lbl_value = _RealNameNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 手机号码 </ td >< td >
< asp:TextBox ID ="txtPhone" runat ="server" Width ="180px" type ="text" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPhone" ></ span >
< asp:CustomValidator
ID ="CustomValidator7"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPhone"
ClientValidationFunction ="ClientValidatorPhone" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPhone(oSrc, args) {
var txt = document.getElementById( ' <%=txtPhone.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPhone " );
var lbl_value = _MobileNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >
< td class ="userRegisterTDLeft" colspan ="2" >
< span style ="color: #FF0000;" > 注: </ span > 真实姓名和身份证号为领奖唯一凭证,请如实填写。 </ td >
</ tr >
</ table >
< tr >< td colspan ="2" align ="center" class ="userRegisterTableHead" > 注册资料 </ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 注册帐号 </ td >< td >
< asp:TextBox ID ="txtLoginName" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanLoginName" ></ span >
< asp:CustomValidator
ID ="CustomValidator1"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtLoginName"
ClientValidationFunction ="ClientValidatorLoginName" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorLoginName(oSrc, args) {
var txt = document.getElementById( ' <%=txtLoginName.ClientID %> ' ).value;
var lbl = document.getElementById( " spanLoginName " );
var lbl_value = _LoginName(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ● < span
class ="userRegisterSpan" > 以字母开头, </ span > 由字母a-z(不区分大小写)、数字0-9、下划线组成 </ span >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ●长度:4-16个字符 </ span >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 密码 </ td >< td >
< asp:TextBox ID ="txtPassword" runat ="server" TextMode ="Password" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPassword" ></ span >
< asp:CustomValidator
ID ="CustomValidator2"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPassword"
ClientValidationFunction ="ClientValidatorPassword" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPassword(oSrc, args) {
var txt = document.getElementById( ' <%=txtPassword.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPassword " );
var lbl_value = _PassWord(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" ></ td >< td >< span class ="userRegisterSpan" > ●密码长度6-16位,字母区分大小写 </ span >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 确认密码 </ td >< td >
< asp:TextBox ID ="txtPasswordAgain" runat ="server" TextMode ="Password" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPasswordAgain" ></ span >
< asp:CustomValidator
ID ="CustomValidator3"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPasswordAgain"
ClientValidationFunction ="ClientValidatorPasswordAgain" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPasswordAgain(oSrc, args) {
var txt1 = document.getElementById( ' <%=txtPassword.ClientID %> ' ).value;
var txt2 = document.getElementById( ' <%=txtPasswordAgain.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPasswordAgain " );
var lbl_value = _PassWordAgain(txt1, txt2);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 电子邮箱 </ td >< td >
< asp:TextBox ID ="txtEmail" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanEmail" ></ span >
< asp:CustomValidator
ID ="CustomValidator4"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtEmail"
ClientValidationFunction ="ClientValidatorEmail" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorEmail(oSrc, args) {
var txt = document.getElementById( ' <%=txtEmail.ClientID %> ' ).value;
var lbl = document.getElementById( " spanEmail " );
var lbl_value = _EmailNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 身份证号 </ td >< td >
< asp:TextBox ID ="txtCardID" runat ="server" Width ="180px" AutoCompleteType ="Disabled" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanCardID" ></ span >
< asp:CustomValidator
ID ="CustomValidator5"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtCardID"
ClientValidationFunction ="ClientValidatorCardID" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorCardID(oSrc, args) {
var txt = document.getElementById( ' <%=txtCardID.ClientID %> ' ).value;
var lbl = document.getElementById( " spanCardID " );
var cardID = txt + " ,2,0 " ;
var lbl_value = _ChinaCardNo(cardID);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >< td class ="userRegisterTDLeft" > 真实姓名 </ td >< td >
< asp:TextBox ID ="txtRealName" runat ="server" Width ="180px" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanRealName" ></ span >
< asp:CustomValidator
ID ="CustomValidator6"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtRealName"
ClientValidationFunction ="ClientValidatorRealName" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorRealName(oSrc, args) {
var txt = document.getElementById( ' <%=txtRealName.ClientID %> ' ).value;
var lbl = document.getElementById( " spanRealName " );
var lbl_value = _RealNameNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr >< td class ="userRegisterTDLeft" > 手机号码 </ td >< td >
< asp:TextBox ID ="txtPhone" runat ="server" Width ="180px" type ="text" CausesValidation ="true" ></ asp:TextBox >
< span id ="spanPhone" ></ span >
< asp:CustomValidator
ID ="CustomValidator7"
runat ="server"
ErrorMessage =""
ValidationGroup ="AAA"
ValidateEmptyText ="true"
SetFocusOnError ="true"
ControlToValidate ="txtPhone"
ClientValidationFunction ="ClientValidatorPhone" >
</ asp:CustomValidator >
< script type ="text/javascript" >
function ClientValidatorPhone(oSrc, args) {
var txt = document.getElementById( ' <%=txtPhone.ClientID %> ' ).value;
var lbl = document.getElementById( " spanPhone " );
var lbl_value = _MobileNo(txt);
lbl.innerHTML = lbl_value;
lbl.style.color = " #ff0000 " ;
args.IsValid = lbl_value == "" ;
}
</ script >
</ td ></ tr >
< tr class ="userRegisterGray" >
< td class ="userRegisterTDLeft" colspan ="2" >
< span style ="color: #FF0000;" > 注: </ span > 真实姓名和身份证号为领奖唯一凭证,请如实填写。 </ td >
</ tr >
</ table >
引用的JS文件里的内容如下:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
//
电子邮箱
function _Email(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$ / ) != - 1 ) {
return "" ;
}
else
{
return " Email格式不正确 " ;
}
}
// 账号--使用ajax,请注册ValidateClass类
// AjaxPro.Utility.RegisterTypeForAjax(typeof(ValidateClass), this.Page);
function _LoginName(elem)
{
var isTrue = ValidateClass.ValidateUserAccount(elem);
return isTrue.value;
}
function _LoginName_admin(elem)
{
var isTrue = ValidateClass.ValidateUserAccount(elem);
return isTrue.value;
}
// 生效时间
function _IsTime(startTime)
{
if (elem == null || elem.length == 0 ) return "" ;
return "" ;
}
// 失效时间
function _AccountTime(Time)
{
if (elem == null || elem.length == 0 ) return "" ;
return "" ;
}
// 身份证号
function _ChinaCard(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
var isTrue = ValidateClass.CardID(elem);
return isTrue.value;
}
// 昵称
// 真实姓名
function _RealName(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length > 50 )
{
return " 真实姓名过长! " ;
}
else { return "" ;}
}
// 省份
// 城市
// 营业部
// 牛卡号
function _NiuCardID(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if ( ! isNumber(elem))
{
return " 请输入正确的牛卡号 " ;
}
else
{
if (elem.length == 8 || elem.length == 10 )
{
return "" ;
}
else
{
return " 请输入正确的牛卡号 " ;
}
}
}
// 手机号码
function _Mobile(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$ / ) !=- 1 )
{
// if (elem.search(/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/)!=-1) {
return "" ;
}
else
{
return " 请输入正确手机号码! " ;
}
}
// 联系电话
function _Phone(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$ / ) != - 1 || elem.search( / ^[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$ / ) != - 1 )
{
return "" ;
}
else
{
return " 请输入正确电话号码! " ;
}
}
// 联系地址
function _Address(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length < 200 )
{
return "" ;
}
else
{
return " 联系地址最长不超过200个字符! " ;
}
return "" ;
}
// 邮编
function _ZipCod(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length != 0 )
{
var reg = / ^\d{6}$ / ;
if (reg.test(elem))
{
return "" ;
}
else
{
return " 邮政编码不正确! " ;
}
}
return "" ;
}
// 密码
function _PassWord(elem)
{
if (elem == null || elem.length == 0 ) return " 密码必须填写 " ;
if (elem.search( / ^(\w){6,16}$ / ) != - 1 )
{
return "" ;
}
else
{
return " 密码只能输入6-16个字母、数字、下划线! " ;
}
}
// 确认密码
function _PassWordAgain(elem, o_elem)
{
if (elem == null || elem.length == 0 ) return " 确认密码必须填写 " ;
if (elem == o_elem)
{
return "" ;
}
else
{
return " 两次密码输入不一致! " ;
}
}
function _StuNumber(elem) {
return "" ;
}
/* *
* 验证是不是数字
*/
function isNumber(oNum)
{
if ( ! oNum) return false ;
var strP = / ^\d+(\.\d+)?$ / ;
if ( ! strP.test(oNum)) return false ;
try
{
if (parseFloat(oNum) != oNum) return false ;
}
catch (ex)
{
return false ;
}
return true ;
}
// 电子邮箱、身份证号、真实姓名、手机号码 学生证号 必填
function _EmailNo(elem)
{
if (elem == null || elem.length == 0 )
{
return " Email必须填写 " ;
}
return _Email(elem);
}
function _ChinaCardNo(elem)
{
var arr = elem.split( " , " );
if (arr[ 0 ] == null || arr[ 0 ].length == 0 )
{
return " 身份证号必须填写 " ;
}
return _ChinaCard(elem);
}
function _RealNameNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 真实姓名必须填写 " ;
}
return _RealName(elem);
}
function _MobileNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 手机号码必须填写 " ;
}
return _Mobile(elem);
}
function _StuNumberNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 学生证号必须填写 " ;
}
return _StuNumber(elem);
}
function _PhoneNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 联系电话必须填写 " ;
}
return _Phone(elem);
}
function trim(str)
{
for ( var i = 0 ; i < str.length && str.charAt(i) == " " ; i ++ );
for ( var j = str.length; j > 0 && str.charAt(j - 1 ) == " " ; j -- );
if (i > j) return "" ;
return str.substring(i, j);
}
// 验证学校
function _SchoolName(elem)
{
var isTrue = ValidateClass.ValidateSchoolForbid(elem);
return isTrue.value;
}
// 验证学院
function _CollegeName(elem)
{
var isTrue = ValidateClass.ValidateCollegeForbid(elem);
return isTrue.value;
}
// 验证专业
function _MajorName(elem)
{
var isTrue = ValidateClass.ValidateMajorForbid(elem);
return isTrue.value;
}
// 验证在读学历
function ValidateEducation(elem)
{
var isTrue = ValidateClass.ValidateEducation(elem);
return isTrue.value;
}
// 验证入学年份
function ValidateEnrollment(elem)
{
var isTrue = ValidateClass.ValidateEnrollment(elem);
return isTrue.value;
}
function _Email(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$ / ) != - 1 ) {
return "" ;
}
else
{
return " Email格式不正确 " ;
}
}
// 账号--使用ajax,请注册ValidateClass类
// AjaxPro.Utility.RegisterTypeForAjax(typeof(ValidateClass), this.Page);
function _LoginName(elem)
{
var isTrue = ValidateClass.ValidateUserAccount(elem);
return isTrue.value;
}
function _LoginName_admin(elem)
{
var isTrue = ValidateClass.ValidateUserAccount(elem);
return isTrue.value;
}
// 生效时间
function _IsTime(startTime)
{
if (elem == null || elem.length == 0 ) return "" ;
return "" ;
}
// 失效时间
function _AccountTime(Time)
{
if (elem == null || elem.length == 0 ) return "" ;
return "" ;
}
// 身份证号
function _ChinaCard(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
var isTrue = ValidateClass.CardID(elem);
return isTrue.value;
}
// 昵称
// 真实姓名
function _RealName(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length > 50 )
{
return " 真实姓名过长! " ;
}
else { return "" ;}
}
// 省份
// 城市
// 营业部
// 牛卡号
function _NiuCardID(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if ( ! isNumber(elem))
{
return " 请输入正确的牛卡号 " ;
}
else
{
if (elem.length == 8 || elem.length == 10 )
{
return "" ;
}
else
{
return " 请输入正确的牛卡号 " ;
}
}
}
// 手机号码
function _Mobile(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$ / ) !=- 1 )
{
// if (elem.search(/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/)!=-1) {
return "" ;
}
else
{
return " 请输入正确手机号码! " ;
}
}
// 联系电话
function _Phone(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.search( / ^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$ / ) != - 1 || elem.search( / ^[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$ / ) != - 1 )
{
return "" ;
}
else
{
return " 请输入正确电话号码! " ;
}
}
// 联系地址
function _Address(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length < 200 )
{
return "" ;
}
else
{
return " 联系地址最长不超过200个字符! " ;
}
return "" ;
}
// 邮编
function _ZipCod(elem)
{
if (elem == null || elem.length == 0 ) return "" ;
if (elem.length != 0 )
{
var reg = / ^\d{6}$ / ;
if (reg.test(elem))
{
return "" ;
}
else
{
return " 邮政编码不正确! " ;
}
}
return "" ;
}
// 密码
function _PassWord(elem)
{
if (elem == null || elem.length == 0 ) return " 密码必须填写 " ;
if (elem.search( / ^(\w){6,16}$ / ) != - 1 )
{
return "" ;
}
else
{
return " 密码只能输入6-16个字母、数字、下划线! " ;
}
}
// 确认密码
function _PassWordAgain(elem, o_elem)
{
if (elem == null || elem.length == 0 ) return " 确认密码必须填写 " ;
if (elem == o_elem)
{
return "" ;
}
else
{
return " 两次密码输入不一致! " ;
}
}
function _StuNumber(elem) {
return "" ;
}
/* *
* 验证是不是数字
*/
function isNumber(oNum)
{
if ( ! oNum) return false ;
var strP = / ^\d+(\.\d+)?$ / ;
if ( ! strP.test(oNum)) return false ;
try
{
if (parseFloat(oNum) != oNum) return false ;
}
catch (ex)
{
return false ;
}
return true ;
}
// 电子邮箱、身份证号、真实姓名、手机号码 学生证号 必填
function _EmailNo(elem)
{
if (elem == null || elem.length == 0 )
{
return " Email必须填写 " ;
}
return _Email(elem);
}
function _ChinaCardNo(elem)
{
var arr = elem.split( " , " );
if (arr[ 0 ] == null || arr[ 0 ].length == 0 )
{
return " 身份证号必须填写 " ;
}
return _ChinaCard(elem);
}
function _RealNameNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 真实姓名必须填写 " ;
}
return _RealName(elem);
}
function _MobileNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 手机号码必须填写 " ;
}
return _Mobile(elem);
}
function _StuNumberNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 学生证号必须填写 " ;
}
return _StuNumber(elem);
}
function _PhoneNo(elems)
{
var elem = trim(elems);
if (elem == null || elem.length == 0 )
{
return " 联系电话必须填写 " ;
}
return _Phone(elem);
}
function trim(str)
{
for ( var i = 0 ; i < str.length && str.charAt(i) == " " ; i ++ );
for ( var j = str.length; j > 0 && str.charAt(j - 1 ) == " " ; j -- );
if (i > j) return "" ;
return str.substring(i, j);
}
// 验证学校
function _SchoolName(elem)
{
var isTrue = ValidateClass.ValidateSchoolForbid(elem);
return isTrue.value;
}
// 验证学院
function _CollegeName(elem)
{
var isTrue = ValidateClass.ValidateCollegeForbid(elem);
return isTrue.value;
}
// 验证专业
function _MajorName(elem)
{
var isTrue = ValidateClass.ValidateMajorForbid(elem);
return isTrue.value;
}
// 验证在读学历
function ValidateEducation(elem)
{
var isTrue = ValidateClass.ValidateEducation(elem);
return isTrue.value;
}
// 验证入学年份
function ValidateEnrollment(elem)
{
var isTrue = ValidateClass.ValidateEnrollment(elem);
return isTrue.value;
}