The input Element
The input element is represented by the HTMLInputElement object. It supports the properties and methods shown in the following table.
Name | Description | Returns |
---|---|---|
accept | the accept attribute | string |
alt | the alt attribute | string |
autocomplete | the autocomplete attribute | string |
autofocus | the autofocus attribute | boolean |
checked | Returns true if the element is checked | boolean |
dirName | the dirname attribute | string |
disabled | the disabled attribute | boolean |
form | the form attribute | string |
formAction | the formaction attribute | string |
formEnctype | the formenctype attribute | string |
formMethod | the formmethod attribute | string |
formNoValidate | the formnovalidate attribute | string |
formTarget | the formtarget attribute | string |
list | the list attribute | HTMLElement |
max | the max attribute | string |
maxLength | the maxlength attribute | number |
min | the min attribute | string |
multiple | the multiple attribute | boolean |
name | the name attribute | string |
pattern | the pattern attribute | string |
placeholder | the placeholder attribute | string |
readOnly | the readonly attribute | boolean |
required | the required attribute | boolean |
size | the size attribute | number |
src | the src attribute | string |
step | the step attribute | string |
type | the type attribute | string |
value | the value attribute | string |
valueAsDate | Gets or sets the value attribute as a date object | Date |
valueAsNumber | Gets or sets the value attribute as a number | number |
selectedOption | Gets the option element from the datalist specified by the list attribute that matches the input element's value | HTMLOptionElement |
stepUp(<step>) | Increases the value by the specified amount | void |
stepDown(<step>) | Decreases the value by the specified amount | void |
willValidate | Returns true if the element will be subject to input validation when the form is submitted; returns false otherwise | boolean |
validity | Returns an assessment of the validity of the input | ValidityState |
validationMessage | Returns the error message that would be shown to the user if input validation was applied | string |
checkValidity() | Performs input validation | boolean |
setCustomValidity(<msg>) | Sets a custom validation message | void |
labels | Returns the label elements associated with this element | HTMLLabelElement[] |