前端之家收集整理的这篇文章主要介绍了
微信小程序表单验证功能完整实例,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
required: true,minlength: 2,maxlength: 10,},mobile: {
required: true,tel: true,company: {
required: true,maxlength: 100,client: {
required: true,}
},{
name: {
required: '请填写您的姓名姓名',mobile: {
required: '请填写您的手机号',company: {
required: '请输入公司
名称',client: {
required: '请输入绑定客户',}
}
)
},//表单提交
formSubmit: function (e) {
//提交
错误描述
if (!this.WxValidate.checkForm(e)) {
const error = this.WxValidate.errorList[0]
// `${error.param} : ${error.msg} `
wx.showToast({
title: `${error.msg} `,image: '/pages/images/error.png',duration: 2000
})
return false
}
this.setData({ submitHidden: false })
var that = this
//提交
wx.request({
url: '',data: {
Realname: e.detail.value.name,Gender: e.detail.value.gender,Mobile: e.detail.value.mobile,Company: e.detail.value.company,client: e.detail.value.client,Identity: appInstance.userState.identity
},method: 'POST',success: function (requestRes) {
that.setData({ submitHidden: true })
appInstance.userState.status = 0
wx.navigateBack({
delta: 1
})
},fail: function () {
},complete: function () {
}
})
}