如果未选中复选框,则禁用按钮 [英] Disable button if checkbox is not checked

查看:118
本文介绍了如果未选中复选框,则禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

如果用户没有选中复选框,我基本上想要禁用该按钮。

我不知道为什么它不工作,甚至不工作识别我的按钮ID



这是我的代码:



 <   input    类型  = 复选框   名称  =  one    id   = 一个  /  >  
< label = 一个 > 我已阅读并接受条款和条件< / label >
< br / >

< div class = col-sm-12 >
< 按钮 类型 = 提交 名称 = btnnext id = btnnext class = btn btn-primary btn-primary > 下一步< span = glyphicon glyphicon-chevron-right > < / span > < /按钮 >
< / div >

< < span class =code-leadattribute> script type = text / javascript >
var checkBoxes = $(' one');
checkBoxes.change( function (){
$(' #btnnext')。prop(' disabled', checkBoxes.filter(' :checked')。length< 1 );
});
checkBoxes.change();
< / script >

解决方案

' one');
checkBoxes.change( function (){


' #btnnext')。prop(' 已禁用',checkBoxes.filter(' :checked')。length< 1 );
});
checkBoxes.change();
< / script >


点击此处...免费...开始工作...... https://www.hscripts.com/scripts/JavaScript /enable-submit.php [ ^

Hi guys.
I basically want the button to be disabled if the user does not check the check box.
I dont know why it isnt working, not even recognising my button id

Here's my code:

            <input type="checkbox" name="one" id="one"/>
            <label for="one">I have read and I accept the terms and conditions</label>
            <br />

<div class="col-sm-12">
            <button type="submit" name="btnnext" id="btnnext" class="btn btn-primary btn-primary">Next<span class="glyphicon glyphicon-chevron-right"></span></button>
        </div>

<script type="text/javascript">
        var checkBoxes = $('one');
        checkBoxes.change(function () {
        $('#btnnext').prop('disabled', checkBoxes.filter(':checked').length < 1);
        });
        checkBoxes.change();
    </script>

解决方案

('one'); checkBoxes.change(function () {


('#btnnext').prop('disabled', checkBoxes.filter(':checked').length < 1); }); checkBoxes.change(); </script>


Click Here...Feel Free ...And Start Work...https://www.hscripts.com/scripts/JavaScript/enable-submit.php[^]


这篇关于如果未选中复选框,则禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆