Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
Disable button if checkbox is checked and label is a specific text

I have a table with a datagrid (checkboxes and labels in each row). I want to disable a button by checking if a label is "Forbidden". The user can check multiple checkboxes. So my question is how do I get all the checked checkboxes and then check if the label in each selected row is of value "Forbidden" so I can disable the button.

I tried something like this:

$(function() {
    checkboxes = document.querySelectorAll('[id=checkId]');
    var validateBtn = $('button[name="btnVal"]');
    checkboxes.forEach((cb) => {
        cb.addEventListener('change', checkStatus);
    });
    function checkStatus() {
        //to-do
        // if ($(this).is(":checked")) {
            
            var label = document.getElementById('statusLabel');
            if (label.textContent == "Forbidden") {
                validateBtn.prop('disabled', true);
            }
        }
    });

The table looks like this:enter image description here In this case the button should be disabled as we have selected a forbidden status.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can check the property of the checkbox and disable the button according to this will be:

$('#id_of_your_checkbox').click(function() {
    if ($(this).is(':checked')) {
        $('#id_of_your_button').attr('disabled', 'disabled');
    } else {
        $('#id_of_your_button').removeAttr('disabled');
    }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!