HTML Required Attribute Works on Select Elements
If you are using the HTML required attribute, you may need to adjust how you are writing select elements to make it work correctly. It is a very common pattern to start your HTML select element with an option that prompts the user to select from the list, for example “Please select…” or “Select your country…” or something similar.
This pattern requires a quick bit of validation to ensure that the user has selected an option, rather than leaving the “Please select…” option selected.
<form method="post" action=""> <select required> <option value="">Please select</option> <option value="1">One</option> <option value="2">Two</option> </select> <button>Submit</button> </form>
If you are living it long-hand, use the following: