Answers for "default in drop box in html"

7

select dropdown default value

<select>
  <option value="" selected disabled hidden>Choose here</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
  <option value="4">Four</option>
  <option value="5">Five</option>
</select>
Posted by: Guest on May-03-2020
0

html form reject default drop down list

//To force form validation on a select input:
//you need to use the required attribute on your select form and
//set the value of the initial option to "".
//Notice that you have to set the value -""- as invalid
<form>
  <select id="cars" name="cars" required aria-invalid="">//Required tag + "" is considered invalid
	<option value="" selected disabled hidden>Choose car...</option> //Default option
	  <option value="volvo">Volvo XC90</option>
	  <option value="saab">Saab 95</option>
	  <option value="mercedes">Mercedes SLK</option>
	  <option value="audi">Audi TT</option>
</select>
  <button type="submit">Submit</button>
</form>
Posted by: Guest on December-26-2020

Browse Popular Code Answers by Language