Our select tags display an empty option tag at the beginning to ensure users don't automatically select the first option otherwise displayed:
<select name="title" required pattern="[A-Z]">
<option value="0"></option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>
How do we validate the select tag to ensure one of the options OTHER than 0 is selected?
Perferably without Javascript!!
Set value=""
for the first option and the required
validation will behave as expected:
<form>
<select name="title" required>
<option value="">Select One</option>
<option value="1">First Value</option>
</select>
<button>submit</button>
</form>
Keep in mind browser support when leveraging HTML5 form validation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With