I have a multiple select from which I need to check the value with jquery. I need to know how to pick up the value of that select, because if it's empty it returns this:
But putting it in a if ([] === $("#comercial_lista_calc").val())
returns false
and if I put !==
it does not work correctly either because it does not enter the if.
<label for="comercial_lista_calc">{{ "Comercial"|trans }}</label><br>
<select id="comercial_lista_calc" name="comercial_lista_calc[]" class="chosen selectMed" multiple="true">
<option value="todos">{{ "Todos.comerciales"|trans }}</option>
{% for comercial in comerciales %}
<option value="{{ comercial.id }}">{{ comercial.username|title }}</option>
{% endfor %}
</select>
The solution has been this: if(0 < $("#comercial_lista_calc").val().length)