yad4u Detect if an element is selected in listbox or not through jquery


Detect if an element is selected in listbox or not through jquery



I have a multiselect listbox and before submitting the form i want to check whether user select any option or not through jquery


asp.net mvc 2 - Model Binding and Select Lists

1:

Simple DropDownListFor in MVC2?
You could use the .val() function to receive the selected values. Is it acceptable to have unhandled exceptions in ASP.NET web applications?For a multi select it returns an array of the selected values or null if no element has been selected:. How to handle splitted date fields (year, month, day) in ASP.NET MVC
if ($('#idofselect').val() != null) {     // user has selected at least one value } 
ASP.NET MVC with DDD architecturehow to manage image file in c# for asp.net mvc web-application

2:

erb <% expression -%> in aspx pages
Does this job for you:. ASP.NET MVC Routing not Working in Virtual Directory
$("#formID").submit(function() {   var selectValue = $('#selectList').val();   if(selectValue != null)   {       // blah   } }); 

3:

$('#list option:selected').length 
Will receive the amount of selected objects i think. (replace '#list' with your selector obviously)..


51 out of 100 based on 46 user ratings 161 reviews