//手机验证: |
$( "#txtphone" ).blur(function () { |
var mobel = $( "#txtphone" ).val().replace( "/\s+/g" , "" ); |
var pattern = /^(?: 13 \d| 15 [ 89 ])-?\d{ 5 }(\d{ 3 }|\*{ 3 })$/; |
$(this).parent().children( ".chk_tips" ).remove(); |
if (mobel != "" ) { |
if (!pattern.exec(mobel)) { |
$(this).parent().append(error); |
$(this).parent().children( ".chk_tips" ).html( "您输入的手机号码有误" ); |
} else { |
$(this).parent().children( ".chk_tips" ).html( "" ); |
} |
} |
}) |
//联系电话的验证: |
$( "#txtcontacttel" ).blur(function(){ |
var phone=$( "#txtcontacttel" ).val().replace( '/\s+/g' , '' ); |
$(this).parent().children( ".chk_tips" ).remove(); |
if(phone!= "" ){ |
var p 1 = /^(([ 0 \+]\d{ 2 , 3 }-)?( 0 \d{ 2 , 3 })-)?(\d{ 7 , 8 })(-(\d{ 3 ,}))?$/; |
if(!p 1 .test(phone)){ |
$(this).parent().append(error); |
$(this).parent().children( ".chk_tips" ).html( "您输入的电话号码有误" ); |
}else{ |
$(this).parent().children( ".chk_tips" ).html( "" ); |
} |
} |
}) |
//QQ或MSN的验证: |
$( "#txtcontact" ).blur(function(){ |
var IM=$( "#txtcontact" ).val(); |
$(this).parent().children( ".chk_tips" ).remove(); |
if(IM!= "" ){ |
if (IM.search(/^[ 1 -9 ]\d{ 4 , 11 }$/)!= -1 ){ |
$(this).parent().children( ".chk_tips" ).html( "" ); |
}else if(IM.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z 0 -9 ]+((\.|-)[A-Za-z 0 -9 ]+)*\.[A-Za-z 0 -9 ]+$/) != -1 ){ |
$(this).parent().children( ".chk_tips" ).html( "" ); |
}else{ |
$(this).parent().append(error); |
$(this).parent().children( ".chk_tips" ).html( "您输入的QQ或MSN有误" ); |
} |
} |
}) |
//去掉特殊字符: |
$( "#txtstoreaddress" ).blur(function() { |
$( "#setmap" ). show (); |
$(this).parent().children( ".chk_tips" ).remove(); |
if($.trim(this.value) != "" ){ |
var reg = new RegExp( "[`~!@#$%^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]" ); |
if (reg.test($.trim(this.value))){ |
$( "#setmap" ). hide (); |
$(this).parent().append(error); |
$(this).parent().children( ".chk_tips" ).html( "您输入的内容含有不合法字符" ); |
}else{ |
$(this).parent().children( ".chk_tips" ).html( "" ); |
$( "#setmap" ). show (); |
} |
} |
}); |
//邮箱: |
var regemail = /^([a-zA-Z 0 -9 ]+[-|\_|\_|\.]?)*[a-zA-Z 0 -9 ]+@([a-zA-Z 0 -9 ]+[-|\_|\_|\.]?)*[a-zA-Z 0 -9 ]+\.[a-zA-Z]{ 2 , 3 }$/; |
if (!regemail.test(email)) { |
$( "#regmsg" ).html( "邮箱地址有误" ); |
return; |
} |