Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the select element have the required attribute?

Yes you can use required attribute in HTML5. But remember, first value should be empty.

<select required>
<option value="">Please select</option>
<option value="first">First</option>
</select>

Here you get the more example:

http://dev.w3.org/html5/spec-author-view/the-select-element.html#the-select-element


Yes it has a required attribute, you can use it as follows

<select required>
<option value="" disabled selected>Choose</option>
<option value="first Option">First Option</option>
<option value="Second Option">Second Option</option>
</select>

Reference :

HTML Select required Attribute (W3C)


You can do this way to make it look better

    <select required>
    <option hidden="" disabled="disabled" selected="selected" value="">Select subject</option>
    <option value="first Option">First Option</option>
    <option value="Second Option">Second Option</option>
    </select>