0

When I want to check if an input field has a value I can use

document.getElementById('datum').value == false

But how to check if there is a value selected in a multiple select?

<select multiple id="letsel_soort[]" name="letsel_soort[]" multiple="multiple" onkeyup="validate()" onmousemove="validate()">
Muiter
  • 1,470
  • 6
  • 26
  • 39
  • 1
    If you use jquery you could use $("select[name='letsel_soort[]'] option:selected").length; – clearshot66 Sep 25 '17 at 19:47
  • Possible duplicate of [How to get all selected values of a multiple select box?](https://stackoverflow.com/questions/5866169/how-to-get-all-selected-values-of-a-multiple-select-box) – Terry Sep 25 '17 at 19:53
  • @terry, no duplicate. I just need to check if there are any selected before the form is submitted. – Muiter Sep 25 '17 at 19:55
  • You can repurpose that logic to check the number of selected values. >1? Means any is selected. === 0? Means none is selected. – Terry Sep 25 '17 at 19:56

0 Answers0