var input = document.getElementById('thumbimg');
input.addEventListener('change', function() { $("input.imgcheck").attr("disabled", ""); }, false);
I use this code to enable the submit button when the user selects a file to upload.
But what If I want to add more than an upload field? I need to know how to enable the submit button only if all the upload fields are filled. Any Ideas?
Update:
@Simeon made an important comment and he is right. To solve this problem, you can inspect the value of each field and see whether it is empty or not:
I hoped to avoid inspecting every field on each change, but it seems this is unavoidable.
Original answer:
You would have to keep track of which fields have changed. If you have more than one file upload field, you have to use classes, not IDs:
Also, if you use jQuery anyway, then be consistent and use it throughout the script. Especially don’t use
addEventListener, which does not work in IE8 and below. jQuery is there to abstract from this browser differences.