views:

32

answers:

3

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
+1  A: 

Does this work for you:

$("#formID").submit(function()
{
  var selectValue = $('#selectList').val();
  if(selectValue != null)
  {
      // blah
  }
});
Luke Duddridge
A: 
$('#list option:selected').length

Will get the amount of selected objects i think. (replace '#list' with your selector obviously).

Iain