最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jquery验证邮箱和手机号是否正确范例
时间:2022-11-14 22:03:17 编辑:袖梨 来源:一聚教程网
实现源码:
$(function(){
$("#ck_mobile").click(function(){
var mobile = $("#mobile").val();
if(!check_mobile(mobile)){
alert("手机号码格式不正确http://www.*1*11*com.net");
}else{
alert("手机号码正确");
}
});
$("#ck_email").click(function(){
var email = $("#email").val();
if(!check_email(email)){
alert("email格式不正确");
}else{
alert("email正确");
}
});
})
//检查手机号码
function check_mobile(mobile){
if(mobile.length != 11 || isNaN(mobile)){
return false;
}
mobile = mobile.substr(0,3);
//号段
var hd = new Array('130','131','132','133','134','135','136','137','138','139','150','151','152','153','154','155','156','157','158','159','180','181','182','183','184','185','186','187','188','189');
var i = hd.length;
while (i--) {
if (hd[i] == mobile) {
return true;
}
}
return false;
}
//验证邮箱是否正确
function check_email(email){
var reg = /^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/;
if(!reg.test(email)){
return false;
}else{
return true;
}
}
手机号:
Email:
相关文章
- 武林外传十年之约坐骑幻化获取攻略 10-14
- 新月同行22期险境下半月白3c阵容攻略 10-14
- 燕云十六声千夜怎么打-千夜打法攻略 10-14
- 异象回声第五章惊吓莽兽位置分享 10-14
- 胜利女神新的希望最新兑换码分享 10-14
- 盲盒派对雪糕刺客玩法机制解析 10-14