Example question
How do I check if a file has been selected in a <input type="file"> element?
I have multiple checkboxes and a file upload input, I would like to undisable a button if one or more checkbox is checked AND if the input value is not null.
here is a link to bootply
here is 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 js starting point
$('.upload-block [type="checkbox"]').click(function() { if ($(this).is(':checked')) { $('#upload-btn').prop('disabled',false); } else { $('#upload-btn').prop('disabled',true); } });
works for all the checkboxes but I want to add additional condition AND if `#InputFile' has val other than none.
thanks much
I haven't seen the how to ask guidelines lately, but this strikes me as a good question.
on the plus side
- short and correct example code (clearly was edited to become 'short')
- a clear and unambiguous question statement
- appears to have been a thoughtful effort to get a good answer.
on the down side
- doesn't appear to be helpful to future visitors
- the question doesn't indicate whether he tried to answer it on his own
after 4 hours, the question had
3 down votes, zero upvotes (not counting my own)
let's look at the votes. The hover text says the question is regarding whether it is
- shows research effort (hard for me to say, leaning on the not side)
- useful (it was not)
- clear (it was)
so -3 is a bit harsh in my opinion, not a big deal4 close votes
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example. 3
let's look at that
- must include the desired behavior (it does)
- a specific problem (it does (depending on your definition of problem))
- or error (doesn't apply)
- and the shortest code necessary to reproduce it in the question itself. (it does)
So I think by now we've established the close reason does not apply.
I think it is pretty clear this question is not helpful to future visitors, but it seems helpful to this visitor. The visitor is certainly low on tech skills.
My opinion:
I didn't notice where he was being lazy in trying to solve the problem on his own. It is probably a classic "don't know where to begin", and should be accepted as a good question.
It might be appropriate to leave the question open. (in this case the question was answered, forget about it.)
It might be appropriate to introduce an "archived" status that is like closing. It would be worded differently to avoid the negative feeling. It would be used for good questions, already answered, not likely to help future visitors. (I'm not fond of this idea though, just a thought.)
The question was very nicely answered, but clobbering it with close votes is a good way to chase away polite askers. (which we need to keep)
What should we do?
too broad
. Although it is possible to come up with a good answer.