3
 $('#btnSelectAll').click(function() {
       $('.inputchbox').attr('checked', true);
 });

$('#btnCancel').click(function() {
     $('fieldset:not(:checked)').find("input,select,textarea").removeAttr('disabled');
 });

On cancel I need to enable only the checkboxes which are checked? Can I use something like this?

On selectall button I am selecting all the checkboxes from my fieldset but here I need to select only the enabled checkboxes and the not disabled checkboxes.. So checkboxes are disabled on my fieldset on the load it self?

How to exclude disabled checkboxes?

3 Answers 3

6

You can use the (':checkbox:enabled') selector to select only enabled checkboxes.

More info on :checked and :enabled

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

Comments

2

You can use multiple attributes at once i.e.

input:checkbox[name*='name']:checked:enabled

to check if name contains 'name' and checkbox is checked and also enabled, however you should get the length to check in boolean form i.e.

if ($("input:checkbox[name*='name']:checked:enabled").length) {
                    isValid = true;
                }

Comments

1

You can use an intervening filter:

$('.inputchbox').filter(function() { return !this.disabled; }).attr('checked', true);

edit — or you can do like @sAc says and use a filter selector; I have a mental block about those so you probably shouldn't listen to me. It's probably something that happened in my childhood.

1 Comment

That seems to be way to go if that is what OP is looking for possibly, his question isn't that clear though.

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.