what is the best way to check is a drop down contains a value which isnt null.
<select class="dropinput" name="Finish1" id="dropFinish1" tabindex="10" disabled="disabled">
<option value=""></option>
</select>
How to check the above drop down contains no values?
if($('.dropinput > option[value!=""]').length == 0) {
//dropdown contains no non-null options
}
This will check if the select box contains zero options that have a value different than "" (empty).
So the following HTML will be seen as empty in the above jQuery:
<select class="dropinput" name="Finish1" id="dropFinish1" tabindex="10" disabled="disabled">
<option value=""></option>
</select>
The following HTML will not be seen as empty:
<select class="dropinput" name="Finish1" id="dropFinish1" tabindex="10" disabled="disabled">
<option value=""></option>
<option value="some value"></option>
</select>
JSFiddle demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With