国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點(diǎn) > 微信 > 正文

微信小程序手機(jī)號(hào)碼驗(yàn)證功能的實(shí)例代碼

2024-07-22 01:17:27
字體:
供稿:網(wǎng)友

wxml

<form bindsubmit='formSubmit'> <view class='all'>  <text>手機(jī)號(hào):</text>  <input name="phone" placeholder='請(qǐng)輸入手機(jī)號(hào)' type='number' style='color:#333' placeholder-style="color:#666" maxlength="11" bindinput='blurPhone'></input> </view> <button formType="submit">保存</button></form>

wxss

.all { border-top: 1rpx solid #efefef; border-bottom: 1rpx solid #efefef; height: 98rpx; font-size: 28rpx; display: flex; align-items: center;}button { width: 480rpx; height: 80rpx; background-color: #7ecffd; font-size: 30rpx; color: #fff; border-radius: 8px; margin: 50rpx auto;}

js

Page({ /**  * 頁面的初始數(shù)據(jù)  */ data: {  ajxtrue: false, }, // 手機(jī)號(hào)驗(yàn)證 blurPhone: function(e) {  var phone = e.detail.value;  let that = this  if (!(/^1[34578]/d{9}$/.test(phone))) {   this.setData({    ajxtrue: false   })   if (phone.length >= 11) {    wx.showToast({     title: '手機(jī)號(hào)有誤',     icon: 'success',     duration: 2000    })   }  } else {   this.setData({    ajxtrue: true   })   console.log('驗(yàn)證成功', that.data.ajxtrue)  } }, // 表單提交 formSubmit(e) {  let that = this  let val = e.detail.value  let ajxtrue = this.data.ajxtrue  if (ajxtrue == true) {   //表單提交進(jìn)行  } else {   wx.showToast({    title: '手機(jī)號(hào)有誤',    icon: 'success',    duration: 2000   })  } }, /**  * 生命周期函數(shù)--監(jiān)聽頁面加載  */ onLoad: function(options) { }, /**  * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成  */ onReady: function() { }, /**  * 生命周期函數(shù)--監(jiān)聽頁面顯示  */ onShow: function() { }, /**  * 生命周期函數(shù)--監(jiān)聽頁面隱藏  */ onHide: function() { }, /**  * 生命周期函數(shù)--監(jiān)聽頁面卸載  */ onUnload: function() { }, /**  * 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作  */ onPullDownRefresh: function() { }, /**  * 頁面上拉觸底事件的處理函數(shù)  */ onReachBottom: function() { }, /**  * 用戶點(diǎn)擊右上角分享  */ onShareAppMessage: function() { }})

下面看下微信小程序正則判斷手機(jī)號(hào)的示例代碼

var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+/d{8})$/;if (this.data.Del.length == 0) { wx.showToast({  title: '輸入的手機(jī)號(hào)為空',  icon: 'success',  duration: 1500 }) return false;} else if (this.data.Del.length < 11) { wx.showToast({  title: '手機(jī)號(hào)長度有誤!',  icon: 'success',  duration: 1500 }) return false;} else if (!myreg.test(this.data.Del)) { wx.showToast({  title: '手機(jī)號(hào)有誤!',  icon: 'success',  duration: 1500 }) return false;} else { wx.showToast({  title: '填寫正確',  icon: 'success',  duration: 1500 })}

總結(jié)

以上所述是小編給大家介紹的微信小程序手機(jī)號(hào)碼驗(yàn)證功能的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)錯(cuò)新站長站網(wǎng)站的支持!

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 沁阳市| 鱼台县| 台湾省| 岳西县| 闵行区| 富源县| 交城县| 高清| 苏州市| 莒南县| 靖西县| 墨脱县| 前郭尔| 开封县| 陈巴尔虎旗| 阿克苏市| 平罗县| 耿马| 浙江省| 黄陵县| 桐乡市| 陆川县| 南皮县| 进贤县| 泾阳县| 璧山县| 合作市| 元江| 张掖市| 阿图什市| 江口县| 西平县| 肇州县| 和田市| 措勤县| 南陵县| 广元市| 吉隆县| 广元市| 华蓥市| 日喀则市|