1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //验证邮政编码 $("#postcode").blur(function(){ //获取邮政编码 var postcode=$("#postcode").val(); if(is_postcode(postcode)){ $("#postcode_info").html(""); }else{ $("#postcode_info").html("邮编格式不正确"); return false; } }); //验证手机号码 $("#mobile").blur(function(){ //获取手机号,并去除左右两边空格 var mobile=$.trim($("#mobile").val()); if(is_mobile(mobile)){ $("#mobile_info").html(""); }else{ $("#mobile_info").html("手机号格式不正确"); return false; } }); //验证email $("#email").blur(function(){ //获取email var email=$("#email").val(); if(is_email(email)){ $("#email_info").html(""); }else{ $("#email_info").html("电子邮件格式不正确"); return false; } }); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | //订单提交页-验证邮政编码 function is_postcode(postcode) { if ( postcode == "") { return false; } else { if (! /^[0-9][0-9]{5}$/.test(postcode)) { return false; } } return true; } //订单提交页-验证手机号 function is_mobile(mobile) { if( mobile == "") { return false; } else { if( ! /^0{0,1}(13[0-9]|15[0-9]|18[0-9]|14[0-9])[0-9]{8}$/.test(mobile) ) { return false; } return true; } } //订单提交页-验证email的合法性 function is_email(email) { if ( email == "") { return false; } else { if (! /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/.test(email)) { return false; } } return true; } |
2019年7月21日 下午4:46 沙发
非技术的路过。
2019年7月30日 下午5:03 1层
@QQ游客 多多路过哦
2019年7月27日 上午11:25 板凳
不错
2019年7月30日 下午5:02 1层
@杂烩网 [捂手][握手]