Search code examples
javascriptforms

Forcing change of option in required select


I have a select where the first option is a placeholder. It has disabled, hidden, selected attributes. Select is set as required. How to prevent users from submitting the form with the first option checked by default? Thanks

<select id="pick-option" required>
  <option disabled hidden selected>choose:</option>
  <option>1</option>
  <option>2</option>
  <option>3</option>
<select>

Solution

  • You can set value="" on the default option.

    Check out this example: https://codepen.io/dusanjovanov92/pen/rNZqVZw