微信小程序判断输入的手机号是否正确
直接上项目中的部分代码;
onClickOk: function(event) {
var phone = this.data.mobile
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
if (!phone || phone.length != 11 || !myreg.test(phone)) {
wx.showToast({
title: '手机格式不正确',
icon: 'none'
})
return
}
this._httpUpdateInfo(phone)
},