The input Element

The input element is represented by the HTMLInputElement object. It supports the properties and methods shown in the following table.

NameDescriptionReturns
acceptthe accept attributestring
altthe alt attributestring
autocompletethe autocomplete attributestring
autofocusthe autofocus attributeboolean
checkedReturns true if the element is checkedboolean
dirNamethe dirname attributestring
disabledthe disabled attributeboolean
formthe form attributestring
formActionthe formaction attributestring
formEnctypethe formenctype attributestring
formMethodthe formmethod attributestring
formNoValidatethe formnovalidate attributestring
formTargetthe formtarget attributestring
listthe list attributeHTMLElement
maxthe max attributestring
maxLengththe maxlength attributenumber
minthe min attributestring
multiplethe multiple attributeboolean
namethe name attributestring
patternthe pattern attributestring
placeholderthe placeholder attributestring
readOnlythe readonly attributeboolean
requiredthe required attributeboolean
sizethe size attributenumber
srcthe src attributestring
stepthe step attributestring
typethe type attributestring
valuethe value attributestring
valueAsDateGets or sets the value attribute as a date objectDate
valueAsNumberGets or sets the value attribute as a numbernumber
selectedOptionGets the option element from the datalist specified by the list attribute that matches the input element's valueHTMLOptionElement
stepUp(<step>) Increases the value by the specified amountvoid
stepDown(<step>) Decreases the value by the specified amountvoid
willValidateReturns true if the element will be subject to input validation when the form is submitted; returns false otherwiseboolean
validityReturns an assessment of the validity of the inputValidityState
validationMessageReturns the error message that would be shown to the user if input validation was appliedstring
checkValidity()Performs input validationboolean
setCustomValidity(<msg>) Sets a custom validation messagevoid
labelsReturns the label elements associated with this elementHTMLLabelElement[]
Home 
  JavaScript Book 
    DOM