0

I am using jQuery trying to validate that a checkbox has been checked before allowing a user to click on a 'Proceed' button.

The 'Proceed' button is set 'Enable = false' when the page loads.

So far I have tried :

// On check of the accept terms checkbox
             $(".chkTandCs").change(function () {
                 // If checked, enable the Continue button, else, disable it.
                 if ($(this).is(":checked")) {
                     $(".lbnAcceptCurrent").removeAttr('disabled');
                 }
                 else {
                     $(".lbnAcceptCurrent").attr("disabled", "disabled");
                 }
             });

This hasn't worked.

The checkbox and 'Proceed' button are inside a modal that opens when a different button has been clicked.

All help very much appreciated

1 Answer 1

1

Use prop() instead

$(".chkTandCs").change(function () {
     $(".lbnAcceptCurrent").prop('disabled', !this.checked);
});

If the modal generates the markup dynamically, you'll need to delegate

$(document).on('change', '.chkTandCs', function () {
     $(".lbnAcceptCurrent").prop('disabled', !this.checked);
});

and replace document with the closest static parent element of the modal

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.