I have a multiselect listbox and before submitting the form i want to check whether user select any option or not through jquery
+2
A:
You could use the .val()
function to get the selected values. For a multi select it returns an array of the selected values or null if no element has been selected:
if ($('#idofselect').val() != null) {
// user has selected at least one value
}
Darin Dimitrov
2010-06-22 12:10:39
+1
A:
Does this work for you:
$("#formID").submit(function()
{
var selectValue = $('#selectList').val();
if(selectValue != null)
{
// blah
}
});
Luke Duddridge
2010-06-22 12:16:58
A:
$('#list option:selected').length
Will get the amount of selected objects i think. (replace '#list' with your selector obviously).
Iain
2010-06-23 00:02:44