html form reject default drop down list

Solutions on MaxInterview for html form reject default drop down list by the best coders in the world

showing results for - "html form reject default drop down list"
Amy
29 Apr 2016
1//To force form validation on a select input:
2//you need to use the required attribute on your select form and
3//set the value of the initial option to "".
4//Notice that you have to set the value -""- as invalid
5<form>
6  <select id="cars" name="cars" required aria-invalid="">//Required tag + "" is considered invalid
7	<option value="" selected disabled hidden>Choose car...</option> //Default option
8	  <option value="volvo">Volvo XC90</option>
9	  <option value="saab">Saab 95</option>
10	  <option value="mercedes">Mercedes SLK</option>
11	  <option value="audi">Audi TT</option>
12</select>
13  <button type="submit">Submit</button>
14</form>