微信小程序?qū)崿F(xiàn)手機(jī)號(hào)碼驗(yàn)證
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)手機(jī)號(hào)碼驗(yàn)證的具體代碼,供大家參考,具體內(nèi)容如下
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() {
?
? }
})以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- uniapp抖音小程序一鍵獲取用戶手機(jī)號(hào)的示例代碼
- UNIAPP實(shí)現(xiàn)微信小程序登錄授權(quán)和手機(jī)號(hào)授權(quán)功能(uniapp做微信小程序)
- 微信小程序獲取用戶手機(jī)號(hào)碼詳細(xì)教程(前端+后端)
- 微信小程序中獲取用戶手機(jī)號(hào)授權(quán)登錄詳細(xì)步驟
- uniapp微信小程序授權(quán)登錄并獲取手機(jī)號(hào)的方法
- uniapp+.net?core實(shí)現(xiàn)微信小程序獲取手機(jī)號(hào)功能
- PHP配合微信小程序?qū)崿F(xiàn)獲取手機(jī)號(hào)碼詳解
- 微信小程序登錄方法之授權(quán)登陸及獲取微信用戶手機(jī)號(hào)
- 微信小程序獲取用戶手機(jī)號(hào)碼的詳細(xì)步驟
- 抖音小程序一鍵獲取手機(jī)號(hào)的實(shí)現(xiàn)思路
相關(guān)文章
js+html5實(shí)現(xiàn)canvas繪制橢圓形圖案的方法
這篇文章主要介紹了js+html5實(shí)現(xiàn)canvas繪制橢圓形圖案的方法,涉及html5圖形繪制的基礎(chǔ)技巧,感興趣的朋友可以參考一下2016-05-05
JS簡單實(shí)現(xiàn)數(shù)組去重的方法示例
這篇文章主要介紹了JS簡單實(shí)現(xiàn)數(shù)組去重的方法,涉及javascript數(shù)組的遍歷、判斷及賦值操作,代碼非常簡單易懂,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03
pnpm install:ERR_PNPM_PEER_DEP_ISSUES Unmet p
這篇文章主要為大家介紹了pnpm install:ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies報(bào)錯(cuò)解決2023-06-06
原生JS實(shí)現(xiàn)點(diǎn)擊數(shù)字小游戲
這篇文章主要為大家詳細(xì)介紹了原生JS實(shí)現(xiàn)點(diǎn)擊數(shù)字小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04
js點(diǎn)擊列表文字對(duì)應(yīng)該行顯示背景顏色的實(shí)現(xiàn)代碼
這篇文章主要介紹了js點(diǎn)擊列表文字對(duì)應(yīng)該行顯示背景顏色的實(shí)現(xiàn)代碼,感興趣的小伙伴可以參考下2015-08-08
javascript關(guān)于“時(shí)間”的一次探索
這篇文章主要介紹了javascript關(guān)于“時(shí)間”的一次探索,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07

