How to limit the number of options selected in a select so that the form is not sent above a maximum amount.
For example, I want a maximum of 3 options to be sent on the form. Above that, I wanted to prevent the user from submitting the form.
How can I do this?
<form action="" method="post">
<select class="form-control" name="options" multiple="multiple">
<option value="1">Opção 1</option>
<option value="2">Opção 2</option>
<option value="3">Opção 3</option>
<option value="4">Opção 4</option>
<option value="5">Opção 5</option>
<option value="6">Opção 6</option>
<option value="7">Opção 7</option>
<option value="8">Opção 8</option>
<option value="9">Opção 9</option>
<option value="10">Opção 10</option>
</select>
<input type="submit" name="send" value="enviar">
</form>