小程序 表单按钮高亮

先看效果

 

其实就是监听每个input获取的值,然后在做判断,看是否有获取到,最后在判断按钮的颜色(看不懂的,可以留言)

   <form bindsubmit='formSubmit'>
      <view class='fill_in'>
          <view>
              <text>收货人</text>  
              <input bindinput='highlightName' name='userName' value='' placeholder='请输入您的姓名' placeholder-style='color:#A0A0A0' /> 
          </view>
          <view>
              <text>手机号码</text>
              <input bindinput='highlightTell' type="number"  maxlength='11' name='tellPhone' value='' placeholder='121232435' placeholder-style='color:#A0A0A0'/>  
          </view>
          <view class='picker'>
            <text>省市区</text>
            <picker mode="region"  bindchange="bindRegionChange"  value="{{region}}"
            custom-item="{{customItem}}" >
                <input placeholder='广东省 广州市 海珠区' 
                       placeholder-style='color:#A0A0A0'
                       disabled
                       name='address'
                       value='{{region[0]}} {{region[1]}} {{region[2]}}'/>
            </picker>
            <image class='icon' src='http://192.168.3.20/images/imageTu/right.png'></image>
          </view>
          <view class='detailAddress'>
            <text>详细地址</text>
            <input bindinput='highlightDeatail' name='addressInfo' value='' placeholder='请输入您的详细地址' placeholder-style='color:#A0A0A0' />
            <view class='location'>
                <image src='http://192.168.3.20/images/imageTu/location.png'></image>
                <text>定位</text>
            </view>
          </view>
      </view>

      <button class="blueBg" hidden='{{lighter}}' form-type='submit'>保存收货地址</button>

      <button class="preservation" hidden='{{!lighter}}'>保存收货地址</button>
      
   </form>

 

 highlightName(e){
    let that = this;
    let userName = e.detail.value;

    if (userName == undefined || userName == '' || that.data.addressInfo == undefined || that.data.addressInfo == "" || that.data.region == undefined || that.data.tellPhone == undefined || that.data.tellPhone == "" ) {
          that.setData({
            lighter: true
          })
    }else{
      that.setData({
        lighter: false
      })
    }

    that.setData({
      userName: userName
    })
    },

  highlightTell(e) {
    let that = this;
    let tellPhone = e.detail.value;

    if (tellPhone == undefined || tellPhone == "" || that.data.addressInfo == undefined || that.data.addressInfo == "" || that.data.region == undefined || that.data.userName == undefined || that.data.userName == "") {
      that.setData({
        lighter: true
      })
    } else {
      that.setData({
        lighter: false
      })
    }

    that.setData({
      tellPhone: tellPhone
    })
  },

  highlightDeatail(e) {
    let that = this;
    let addressInfo = e.detail.value;

    if (addressInfo == undefined || addressInfo == "" || that.data.addressInfo == undefined || that.data.addressInfo == "" || that.data.region == undefined || that.data.userName == undefined || that.data.userName == "") {
      that.setData({
        lighter: true
      })
    } else {
      that.setData({
        lighter: false
      })
    }

    that.setData({
      addressInfo: addressInfo
    })
  },
// _____________按钮高亮_______________//

 

虽然这种方法比较啰嗦啦,但最终效果还是出来了的,如果你有好的方法,欢迎分享留言!!!!

 

转载于:https://www.cnblogs.com/liujun1128/p/10762888.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值