Export (0) Print
Expand All
all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize

required attribute | required property

When present, marks an element that can't be submitted without a value.

This property is read/write.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.10.7.3.6Internet Explorer 10

 

Syntax

HTML
<element required="ptr" ... >

 

JavaScript
object.required = ptr
ptr = object.required

 

Property values

Type: boolean

A boolean attribute that designates an input field as requiring data.

Standards information

Remarks

The attribute can be set on text, text area, URL, email, select, checkbox, or radio button elements. It is a Boolean attribute and needs to be specified only on an element. When users hover the mouse over a required field, they’ll see a tool tip stating that it is a required field.

The following example shows the validation attribute on a text input field.


<p><label>Name: <input type="text" required /></label></p>


See also

HTMLInputElement
HTMLSelectElement
HTMLTextAreaElement

 

 

Show:
© 2014 Microsoft