微信小程序表单验证form提交错误提示
2017-05-18 13:44
901 查看
欢迎来前群里探讨技术QQ:454891743
表单验证 点击确认发布不能为空错误提示
以下是效果图:
代码如下:
WXML:
WXSS:
JS:
表单验证 点击确认发布不能为空错误提示
以下是效果图:
代码如下:
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="请输入留言内容" 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">确认发布</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({ /** * 页面的初始数据 */ data: { }, //确认发布 goDetail:function(e){ setTimeout(()=>{ var subValue = e.detail.value.textarea console.log(subValue) if (subValue == null || subValue == "") { console.log("不能为空") this.setData( { popErrorMsg: "发布的留言内容不能为空" } ); this.ohShitfadeOut(); return; } },100) }, //定时器提示框3秒消失 ohShitfadeOut() { var fadeOutTimeout = setTimeout(() => { this.setData({ popErrorMsg: '' }); clearTimeout(fadeOutTimeout); }, 3000); }, })
相关文章推荐
- 微信小程序表单验证form提交错误提示效果
- 微信小程序表单验证错误提示
- 微信小程序表单验证错误提示效果
- 天河微信小程序入门《四》:融会贯通,form表单提交数据库
- Zend Framework教程之Zend_Form组件实现表单提交并显示错误提示的方法
- 微信小程序 PHP后端form表单提交实例详解
- 微信小程序中form 表单提交和取值实例详解
- 微信小程序 PHP后端form表单提交实例详解
- 微信小程序 form表单提交 点击键盘的完成自动执行
- Discuz X3.1微信打通版,发布回复时出现提示:您的请求来路不正确或表单验证串不符,无法提交问题的解决
- form表单提交数据时进行数据验证并提示弹框
- django - 表单(form)验证及错误提示设置
- 微信小程序中form 表单提交和取值实例详解
- 微信小程序-form表单提交
- 微信小程序 PHP后端form表单提交实例详解
- 微信小程序中form 表单提交和取值实例详解
- 天河微信小程序入门《四》:融会贯通,form表单提交数据库
- 提交表单报400错误,提示 “您提交的数据无法验证”
- Ext JS百强应用:Form验证、表单验证、表单错误提示信息位置 --第4强
- Zend Framework教程之Zend_Form组件实现表单提交并显示错误提示的方法