$("#lq_btn").click(function () {
if (isPhoneNo($.trim($("#mobile").val())) == false) {
alert('请输入合法的手机号码!');
$("#mobile").focus();
return false;
}
if ($.trim($("#yzm").val()).length != 6) {
alert('请输入正确的验证码!');
$("#yzm").focus();
return false;
}
$.ajax({
url: $("#new_welfare").attr('action'),
data: $("#new_welfare").serializeArray(),
type: 'post',
cache: false,
dataType: 'json',
success: function (data) {
alert(data.msg);
//跳回微信公众号
document.addEventListener('WeixinJSBridgeReady', function(){ WeixinJSBridge.call('closeWindow'); }, false);
WeixinJSBridge.call('closeWindow');
},
error: function (data) {
alert(data.msg);
//跳回微信公众号
document.addEventListener('WeixinJSBridgeReady', function(){ WeixinJSBridge.call('closeWindow'); }, false);
WeixinJSBridge.call('closeWindow');
}
})
});
// 验证手机号
function isPhoneNo(phone) {
var pattern = /^1[345789]\d{9}$/;
return pattern.test(phone);
}