Enable a submit button when you click on checkbox or radio button

This section will discuss how we will enable or disable any button when any checkbox or radio button option is selected.
In the below code submit button will enable only when you select any of the checkbox, otherwise it is disabled.

In HTML code there is a tag called FIELDSET we will  use that for this purpose

Your HTML code will look like

 <fieldset>  <div class="form-group options">
    <label>Checkbox</label>
    <div class="input-group">
        <input required type="text" class="form-control" name="options[]" id="option_1"                         placeholder="checkbox" required>
        <div class="input-group-append">
            <span class="input-group-text">
                <input type='checkbox' name="correct_answers[]" value="1" onclick="enableNextButton()">
            </span>
        </div>
    </div>
</div></fieldset>

<button class="btn btn-success" disabled id="submitButton" type="submit" name="button">Submit</button>

Your JQUERY code will look like

 function enableNextButton() {
    $(‘#submitButton’).prop(‘disabled’false);
    }

Tags: No tags

Leave A Comment

Your email address will not be published. Required fields are marked *