Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  181] [ 3]  / answers: 1 / hits: 28728  / 10 Years ago, fri, july 18, 2014, 12:00:00

I have multiple checkboxes and a file upload input. I would like to re-enable a button if one or more checkbox's are checked AND if the input value is not null.



Here is a link to bootply



Here my html



<div class=upload-block>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=file id=InputFile>
<button id=upload-btn type=button blue-button
class=btn blue-button disabled>Submit</button>

</div>


Here is my javascript starting point:
Updated via Karl
Bind a change event on all input and then use some condition:



  $('.upload-block input').change(function() {
$('#upload-btn').prop(
'disabled',
!($('.upload-block :checked').length && $('#InputFile').val()));
});


Example



This works for all the checkboxes and #InputFile has a value other than none. i.e. where a file has been chosen. However this does not work in IE9



How can I update this to work in IE9?


More From » jquery

 Answers
227

Bind a change event on all input and then use some condition:



  $('.upload-block input').change(function() {
$('#upload-btn').prop(
'disabled',
!($('.upload-block :checked').length && $('#InputFile').val()));
});


Example


[#70155] Wednesday, July 16, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antoinette

Total Points: 206
Total Questions: 99
Total Answers: 95

Location: Guam
Member since Tue, Nov 29, 2022
2 Years ago
;