微信小程序 判斷是否是手機(jī)號
JS實現(xiàn)代碼:
validatemobile: function (mobile) { if (mobile.length == 0) { wx.showToast({ title: '請輸入手機(jī)號!', icon: 'success', duration: 1500 }) return false; } if (mobile.length != 11) { wx.showToast({ title: '手機(jī)號長度有誤!', icon: 'success', duration: 1500 }) return false; } var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+/d{8})$/; if (!myreg.test(mobile)) { wx.showToast({ title: '手機(jī)號有誤!', icon: 'success', duration: 1500 }) return false; } return true; }
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答