Last active
August 29, 2015 14:02
-
-
Save lyonsun/2429d05bc91265531fc7 to your computer and use it in GitHub Desktop.
check if at least one option is selected in a multiple select element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select id="mySelect" multiple="multiple"> | |
<option value="1">First</option> | |
<option value="2">Second</option> | |
<option value="3">Third</option> | |
<option value="4">Fourth</option> | |
</select> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
if (!$("#mySelect option:selected").length) | |
// none is selected | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment