欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2018年08月28日 09:14:06   作者:onlineline  
這篇文章主要介紹了微信小程序手機(jī)號(hào)碼驗(yàn)證功能的實(shí)例代碼及微信小程序正則判斷手機(jī)號(hào)的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

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ì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論