微信小程序表单的取值

1.通过<form bindsubmit=”formsubmit”></form>和<button class=”subBtn” hover-class=”curStyle” formType=”submit”组合使用

以下面这个input为例,e.detail.value.username在提交表单的时候就可以获取收货人的值

<input type="text" value="{{name}}" id='userName' name='userName' placeholder="请输入收货人姓名" />

2.在input失焦的时候可以获取到该input的值

<input type='number' id='phone1' placeholder='请填写收卡人手机号' bindblur="phone1Confirm"></input>

phone1Confirm:function(e){
if(e.detail.value.length!=11){
wx.showModal({
title: '温馨提示',
content: '请输入11位手机号',
})
}
var that = this;
that.setData({
phone1: e.detail.value
})
},

猜你喜欢

转载自www.cnblogs.com/liuqianrong/p/9155642.html