同时满足多个文本框不为空值按钮呈现可用激活状态disabled

项目需要,自己写了一个jquery代码,该代码需要满足两个文本框都不为空值,按钮才可用激活状态。

请转载此文的朋友务必附带原文链接,谢谢。

原文链接:http://xuyran.blog.51cto.com/11641754/1827959

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
< html >
     < head >
         < meta  charset = "UTF-8" >
         < meta  name = "viewport"  content = "width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no" >
         < script  src = "../../js/jquery.js" ></ script >
         < script  src = "../../js/mui.min.js" ></ script >
         < link  href = "../../css/mui.min.css"  rel = "stylesheet"  />
         < link  rel = "stylesheet"  href = "../../css/iconfont.css" >
         < link  rel = "stylesheet"  href = "../../css/app.css" >
         < title >红包设置</ title >
         < script >
             $(document).ready( function(){
                  $(".mui-input-row input").keyup(function(){
                    var value2 = $(this).parent().siblings().find("input").val();
                 
             if( this.value !=""&& value2 !=""){
                 $(".sc-btn button").attr("disabled",false);
             }else{$(".sc-btn button").attr("disabled",true);}
           });
 
                 
});
         </ script >
         < style >
             html,body{background: #fef9f4;}
             .mui-content{padding-top: 20px;background: #fef9f4;}
             .mui-input-row,.mui-input-row:last-child{width: 90%;margin: auto;background: #FFFFFF;margin-bottom: 10px;}
             .mui-input-row label{font-family: "微软雅黑";}
             h2{text-align: center;font-weight: normal;padding: 40px 0 0;}
             .sc-btn{width: 90%;margin: auto;padding-top: 80px;}
             .mui-btn-block{padding: 10px 0;}
             .mui-btn-blue{background: #a02227;border: none;}
             .mui-btn-blue.focus-active{background: #a02227;}
         </ style >
         
     </ head >
     < body >
         < div  class = "mui-content" >
         < div  class = "mui-input-row" >
             < label >红包个数</ label >
             < input  type = "text"  placeholder = "填写红包个数" >
         </ div >
         < div  class = "mui-input-row" >
             < label >单个金额</ label >
             < input  type = "text"  placeholder = "填写神灯币" >
         </ div >
         < h2 >¥30个神灯币</ h2 >
          < div  class = "sc-btn" >
           < button  type = "button"  class = "mui-btn mui-btn-blue mui-btn-block"  disabled = "disabled" >付款</ button >
            </ div >
         </ div >
     </ body >
</ html >

效果预览:

wKioL1eO1rXjVrZiAAAy-c4bZpY303.png-wh_50

wKiom1eO1raAu_yWAAAwm9Uqt84231.png-wh_50

本文转自  小旭依然  51CTO博客,原文链接:
http://blog.51cto.com/xuyran/1827959
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值