如果选中复选框,如何禁用或启用 bootstrap 提交按钮

How to disable or enable a bootstrap submit button if checked checkbox

我需要启用或禁用表单上的 bootstrap 提交按钮是否选中复选框

echo "<div class='panel panel-danger'><div class='panel-heading'>OBSERVACIONES</div><div class='panel-body'>";
echo "<div class='input-group'>";
echo "<label class='checkbox-inline'><input type='checkbox' name='visto' id='visto' value=''> Visto bueno del Responsable</label>";
echo "</div>"; 
echo "</div>"; 

...

echo "<input type='submit' class='btn btn-primary' value='SAVE' name='grabaperaus' formaction='update.php'>";

对于复选框,您需要做的就是获取提交 buttonId(在本例中为 grabaperaus)禁用它 onChange checkbox

<input type="checkbox"  
onchange="document.getElementById('grabaperaus').disabled = !this.checked;" name='visto' 
id='visto'/>

试试这个

 
$(document).ready(function(){
    $('#save').prop('disabled', true);

    $('#visto').click(function(){
        if($(this).is(':checked'))
        {
            $('#save').prop('disabled', false);
        }
        else
        {
            $('#save').prop('disabled', true);
        }
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class='checkbox-inline'><input type='checkbox' name='visto' 
id='visto' value=''> Visto bueno del Responsable</label>

<input type='submit' class='btn btn-primary' id="save" value='SAVE' name='grabaperaus' formaction='update.php'>

与Jquery
HTML:

<input type='checkbox' data-toggle='inputid'/>
<input id='inputid'/>

JAVASCRIPT:

function toggle(target) {
    var toggle = $(target).data("toggle");
    if (toggle) {
        var obj = $("#" + toggle);
        if (target.checked) {
            obj.attr("disabled", "disabled");
        } else {
            obj.removeAttr("disabled");
        }
    }
}

$("input:checkbox").each(function(){toggle(this);}).on('input',function(){toggle(this);});