下面一小段代碼給大家介紹微信小程序 功能函數 密碼驗證*,具體代碼如下所示:
//登錄輸入密碼userPasswordInput: function (e) {var that = this;this.setData({userPassword: e.detail.value})// console.log(e.detail.value.length)// console.log(e.detail.value);var value = e.detail.valuevar strkong = /^[0-9a-zA-Z]{0,25}$/g;if (strkong.test(value)) {that.setData({truePwd: true})} else {// console.log("cwoca")wx.showModal({title: '提示',content: '密碼由0~25位由數字和26個英文字母混合而成',showCancel: false,success: function (res) {that.setData({truePwd: false})}})}},
下面給大家介紹微信小程序 功能函數 手機號驗證*,具體代碼如下所示:
// 登錄手機驗證loginPhone: function (e) {var phone = e.detail.value;if (!(/^1[34578]/d{9}$/.test(phone))) {this.setData({ajxtrue: false})if (phone.length >= 11) {wx.showToast({title: '手機號有誤',icon: 'success',duration: 2000})}} else {this.setData({ajxtrue: true})}},
下面一段代碼給大家介紹微信小程序 功能函數 獲取驗證碼*,具體代碼如下所示:
yanZhengInput: function (e) {var that = this;var yanzheng = e.detail.value;var huozheng = this.data.huozhengconsole.log(e.detail.value)that.setData({yanzheng: yanzheng,zhengTrue: false,})if (yanzheng.length >= 4) {if (yanzheng == huozheng) {that.setData({zhengTrue: true,})} else {that.setData({zhengTrue: false,})wx.showModal({content: '輸入驗證碼有誤',showCancel: false,success: function (res) {}})}}},yanzhengBtn: function () {// console.log(app.globalData.userId);var getChange = this.data.getChangevar n = 59;var that = this;var phone = this.data.linPhone;console.log(phone)var user = wx.getStorageSync('user');if (!(/^1[34578]/d{9}$/.test(phone))) {wx.showToast({title: '手機號有誤',icon: 'success',duration: 2000})} else {if (getChange) {this.setData({getChange: false})var time = setInterval(function () {var str = '(' + n + ')' + '重新獲取'that.setData({getText: str})if (n <= 0) {that.setData({getChange: true,getText: '重新獲取'})clearInterval(time);}n--;}, 1000);wx.request({url: 'https://www.didu86.com/Clothes-manager-web/codenum',data: {tel: phone,},header: {'content-type': 'application/json'},success: function (res) {var result = res.data.code;console.log(result)that.setData({huozheng: result,})}})}}},
總結
以上所述是小編給大家介紹的微信小程序 功能函數 手機號、密碼驗證*、獲取驗證碼*,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!
新聞熱點
疑難解答