微信小程序表單驗證form提交錯誤提示效果
更新時間:2020年06月19日 16:31:14 作者:wy_Blog
這篇文章主要為大家詳細介紹了微信小程序表單驗證form提交錯誤提示效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序表單驗證提交錯誤提示的具體代碼,供大家參考,具體內(nèi)容如下
表單驗證,點擊確認發(fā)布不能為空錯誤提示。
以下是效果圖:
代碼如下:
WXML:
<view class="ad_popError" wx:if="{{popErrorMsg}}">{{popErrorMsg}}</view> <view class="ad_popFt"> <form bindsubmit="goDetail" > <textarea class="ad_popArea" bindinput="commentTxtFn" focus="{{isPopOpen}}" placeholder="請輸入留言內(nèi)容" placeholder-style="color:#cccccc;" name="textarea" /> <view class="ad_popCout"> <text class="one_star">你還可以輸入</text> <text class="one_stars {{!!tips?'danger':''}}">{{commentTxtCount}}</text> <text class="one_star">字</text> </view> <button class="informBtn" form-type="submit">確認發(fā)布</button> </form> </view>
WXSS:
page{background: #f4f4f4;} .ad_popHd{height: 76rpx; line-height: 76rpx; font-size: 32rpx;text-align: center; border-bottom: 1px solid #cdd1cd; padding: 0 20rpx;color: #202120;} .ad_popFt{ margin: 20rpx ; margin-top: 50rpx;} .ad_popArea{ width: 708rpx; height:400rpx;font-size:30rpx;padding: 20rpx; box-sizing: border-box; -webkit-box-sizing: border-box; line-height: 40rpx; color: #333; background: #fff; } .ad_popCout{ color: #969899; font-size: 24rpx; text-align: right; line-height: 58rpx; padding: 0 20rpx;} .informBtn{background: #09bb07;color: #fff;font-size: 34rpx; margin-top: 38rpx;height: 88rpx;} .one_stars{color: #999;} .one_star{font-size: 20rpx;color: #999;} .danger{ color: #f64400;} .ad_popError{ background: #de352d; color: #fff; height: 58rpx; line-height: 58rpx; font-size: 24rpx; text-align: center; position: absolute; left: 0; top: 0; width: 100%; z-index:3;}
JS:
// pages/informLeaveMsg/informLeaveMsg.js Page({ /** * 頁面的初始數(shù)據(jù) */ data: { }, //確認發(fā)布 goDetail:function(e){ setTimeout(()=>{ var subValue = e.detail.value.textarea console.log(subValue) if (subValue == null || subValue == "") { console.log("不能為空") this.setData( { popErrorMsg: "發(fā)布的留言內(nèi)容不能為空" } ); this.ohShitfadeOut(); return; } },100) }, //定時器提示框3秒消失 ohShitfadeOut() { var fadeOutTimeout = setTimeout(() => { this.setData({ popErrorMsg: '' }); clearTimeout(fadeOutTimeout); }, 3000); }, })
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
layui實現(xiàn)多圖片上傳并限制上傳的圖片數(shù)量
今天小編就為大家分享一篇layui實現(xiàn)多圖片上傳并限制上傳的圖片數(shù)量,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09推薦幾個不錯的console調(diào)試技巧實現(xiàn)
這篇文章主要介紹了推薦幾個不錯的console調(diào)試技巧實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-12-12利用js制作html table分頁示例(js實現(xiàn)分頁)
這篇文章主要介紹了利用js制作html table的分頁示例(js實現(xiàn)分頁),需要的朋友可以參考下2014-04-04