Created
October 21, 2017 11:10
-
-
Save aayushdrolia/992d4494e73a8bc522e5950b1a4865d7 to your computer and use it in GitHub Desktop.
Restrict multiple select list to max of 2 selections
This file contains 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
<script> | |
jQuery(document).ready(function($){ | |
$('#subjects option').click(function() | |
{ | |
var items = $(this).parent().val(); | |
if (items.length > 2) { | |
alert("You can only select 2 values at a time"); | |
$('#subjects option:selected').prop("selected",false); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment