jquery - 如果没有单击单选按钮,则禁用提交按钮

标签 jquery html radio-button

<tr>
    <td height="250px" width="300px"><center><label><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="LBC") echo "checked";?>  value="LBC"><img src="../paymentoptions/lbc.png" alt="LBC" class="picture" width="245px" style="margin:10px"/></label></td>

    <td height="250px" width="300px"><center><label><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="PickUp") echo "checked";?>  value="PickUp"><img src="../paymentoptions/pickup.jpg" alt="Pick-Up" class="picture" height="210px" width="250px" style="margin:10px"/></label></td>
</tr>

您好,如果没有选择任何选项,我该如何禁用我的表单提交按钮?谢谢

最佳答案

好吧,它们是单选按钮,所以不能取消选中它们。从禁用按钮开始,如果/当其中一个单选按钮被选中时,将其切换为启用:

<input type="submit" disabled="disabled" value="submit" name="submit"/>

//Begin JS

$(function(){
    $("input[type='radio']").change(function(){

        $("input[type='submit']").prop("disabled", false);
        //Or
        //$("input[type='submit']").removeAttr("disabled");
    });
});

JSFiddle

关于jquery - 如果没有单击单选按钮,则禁用提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26081761/

相关文章:

javascript - CSS 选择器(first、first-child、nth-child)在 Javascript/Jquery 中不选择目标

javascript - 在页面上加载高级 jQuery 版本

javascript - Angular JS : input[radio] doesn't work

javascript - jQuery 选择元素的父级并为其使用 prependTo()

php - Bootstrap DataTables - 分页不适用于动态网格系统

php 和 jquery 图像选择器

html - 容器外的文本中心

html - CSS 动画移动不需要的对象

javascript - 如何使用热键检查 jquery 中的单选按钮

javascript - 将相同的事件处理程序添加到单选按钮和复选框