</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2013-01-16 11:23:15Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
Possible Duplicate:
Can I apply the required attribute to <select> fields in HTML5?
I'm using the html5 contact form from here but I'm having issues trying to make the <select>
field required. Everything else works fine, just having trouble with this and the dev hasnt responded when I asked about the field. this is what I have
<select name="package" id="package" title="Please choose a package" class="required">
<option value="">------------------</option>
<option value="basic">Basic</option>
<option value="plus">Plus</option>
<option value="premium">Premium</option>
</select>
What am I missing to get this working correctly?
</div>
I believe that the top answer to this question is what you're looking for. To quote,
This works for me - Have the first value empty - required works on empty values.
<select required> <option value="">Please select</option> <option value="one">One</option> </select>
If you have a better browser, you can try this (like in this
thread):
<select required>
<option value=""></option>
<option value="basic">Basic</option>
<option value="plus">Plus</option>
<option value="premium">Premium</option>
</select>
, but still you should use JavaScript because not a lot of people have browsers that support HTML5 required
attribute. It's not supported by IE and Safari.
check this: http://www.w3.org/TR/html-markup/select.html
global attributes Any attributes permitted globally.
name = string
The name part of the name/value pair associated with this element for the purposes of form submission.
disabled = "disabled" or "" (empty string) or empty
Specifies that the element represents a disabled control.
form = ID reference NEW
The value of the id attribute on the form with which to associate the element.
size = positive integer
The number of options to show to the user.
multiple = "multiple" or "" (empty string) or empty
If present, indicates that its select element represents a control for selecting zero or more options from a list of options. If not present, indicates that its select element represents a control for selecting a single option from a list of options.
autofocus = "autofocus" or "" (empty string) or empty
Specifies that the element represents a control to which a UA is meant to give focus as soon as the document is loaded.
required = "required" or ""
(empty string) or empty
Specifies that the element is a required part of form submission.
so you require a required = "required"
attribute to your <select>