Select only 3 options in dropdown jquery php
<script>
$("#destination_airport").on("change", function()
{
var msg = $("#msg");
var count = 0;
for (var i = 0; i < this.options.length; i++)
{
var option = this.options[i];
option.selected ? count++ : null;
if (count > 3)
{
option.selected = false;
msg.html("Please select at most three options.");
}
}
});
</script>
<script>
$("#destination_airport").on("change", function()
{
var msg = $("#msg");
var count = 0;
for (var i = 0; i < this.options.length; i++)
{
var option = this.options[i];
option.selected ? count++ : null;
if (count > 3)
{
option.selected = false;
msg.html("Please select at most three options.");
}
}
});
</script>
No comments:
Post a Comment