Class Input
The input element represents a form control that allows users to input data. It is a void element that can take many different forms depending on the type attribute, including text fields, checkboxes, radio buttons, file uploads, and more. The input element is one of the most versatile and commonly used form controls in HTML.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccept attribute.alt attribute.autocomplete(String value) autocomplete attribute.autofocus attribute.checked attribute.dirname attribute.disabled attribute.form attribute.formaction(String value) formaction attribute.formenctype(String value) formenctype attribute.formmethod(String value) formmethod attribute.formnovalidate(String value) formnovalidate attribute.formtarget(String value) formtarget attribute.height attribute.inputmode attribute.list attribute.max attribute.maxlength attribute.min attribute.minlength attribute.multiple attribute.name attribute.pattern attribute.placeholder(String value) placeholder attribute.readonly(boolean value) readonly attribute.readonly attribute.required attribute.size attribute.src attribute.step attribute.type attribute.value attribute.width attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Input
public Input()Creates an emptyInputelement. -
Input
Creates anInputelement with the specifiedtype(String)attribute.- Parameters:
type- Thetype(String)attribute. Can benull to unset the attribute.
-
-
Method Details
-
accept
accept attribute.Specifies which file types the file input should accept. Used with
type="file" .Examples:
"image/*" - Accept all image files".pdf,.doc,.docx" - Accept specific file extensions"image/png,image/jpeg" - Accept specific MIME types
- Parameters:
value- File type restrictions for file uploads. Can benull to unset the attribute.- Returns:
- This object.
-
alt
alt attribute.Alternative text for image submit buttons. Used with
type="image" to provide accessible text when the image cannot be displayed.- Parameters:
value- Alternative text for image submit buttons. Can benull to unset the attribute.- Returns:
- This object.
-
autocomplete
autocomplete attribute.Controls whether the browser can automatically complete the input field.
Common values:
"on" - Allow autocomplete (default)"off" - Disable autocomplete"name" - Full name"email" - Email address"username" - Username or login"current-password" - Current password"new-password" - New password"tel" - Telephone number"url" - URL"address-line1" - Street address"country" - Country name"postal-code" - Postal code
- Parameters:
value- Autocomplete hint for the input field. Can benull to unset the attribute.- Returns:
- This object.
-
autofocus
autofocus attribute.Automatically focuses the form control when the page loads. Only one element per page should have this attribute.
-
checked
checked attribute.Whether the command or control is checked.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"checked" - Other values - Passed through as-is
-
dirname
dirname attribute.Specifies the name of a hidden form field that will be submitted along with the input value, containing the text direction (ltr or rtl) of the input content.
This is useful for forms that need to preserve text direction information when submitted. The hidden field will contain either "ltr" or "rtl" based on the input's direction.
- Parameters:
value- The name of the hidden field for directionality information. Can benull to unset the attribute.- Returns:
- This object.
-
disabled
disabled attribute.Whether the form control is disabled.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"disabled" - Other values - Passed through as-is
-
form
form attribute.Associates the input with a form element by specifying the form's ID. This allows the input to be placed outside the form element while still being part of the form.
The value should match the ID of a form element in the same document.
- Parameters:
value- The ID of the form element to associate with this input. Can benull to unset the attribute.- Returns:
- This object.
-
formaction
formaction attribute.URL to use for form submission.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
formenctype
formenctype attribute.Form data set encoding type to use for form submission.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
formmethod
formmethod attribute.HTTP method to use for form submission.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
formnovalidate
formnovalidate attribute.Bypass form control validation for form submission.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
formtarget
formtarget attribute.Browsing context for form submission.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
height
height attribute.Vertical dimension.
-
inputmode
inputmode attribute.Provides a hint to browsers about the type of virtual keyboard to display on mobile devices.
Possible values:
"none" - No virtual keyboard"text" - Standard text keyboard (default)"tel" - Numeric keypad for telephone numbers"url" - Keyboard optimized for URLs"email" - Keyboard optimized for email addresses"numeric" - Numeric keypad"decimal" - Numeric keypad with decimal point"search" - Keyboard optimized for search
- Parameters:
value- The input modality hint for mobile keyboards. Can benull to unset the attribute.- Returns:
- This object.
-
list
list attribute.References a
<datalist> element that provides predefined options for the input field. Creates a dropdown with autocomplete suggestions.- Parameters:
value- The ID of a datalist element (without the # prefix). Can benull to unset the attribute.- Returns:
- This object.
-
max
max attribute.Maximum value.
-
maxlength
maxlength attribute. Maximum length of value. -
min
min attribute.Minimum value.
-
minlength
minlength attribute.Minimum length of value.
-
multiple
multiple attribute.Whether to allow multiple values.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"multiple" - Other values - Passed through as-is
-
name
name attribute.Name of form control to use for form submission and in the form.elements API.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
pattern
pattern attribute.Specifies a regular expression that the input's value must match for the form to be valid. Works with the
title attribute to provide user feedback.- Parameters:
value- A regular expression pattern (e.g.,"[0-9]{3}-[0-9]{3}-[0-9]{4}" for phone numbers). Can benull to unset the attribute.- Returns:
- This object.
-
placeholder
placeholder attribute.Provides a hint to the user about what to enter in the input field. The placeholder text appears when the field is empty and disappears when the user starts typing.
- Parameters:
value- Hint text to display in the empty input field. Can benull to unset the attribute.- Returns:
- This object.
-
readonly
readonly attribute.Whether to allow the value to be edited by the user.
- Parameters:
value- Iftrue , addsreadonly="readonly" . Can benull to unset the attribute.- Returns:
- This object.
-
readonly
readonly attribute.Makes the input field read-only, preventing user modification while still allowing the value to be submitted with the form.
- Parameters:
value- Iftrue , makes the input read-only. Can benull to unset the attribute.- Returns:
- This object.
-
required
required attribute.Indicates that the input field must be filled out before the form can be submitted. Browsers will show validation messages for empty required fields.
- Parameters:
value- Iftrue , makes the input required for form submission. Can benull to unset the attribute.- Returns:
- This object.
-
size
size attribute.Size of the control.
-
src
src attribute.Address of the resource.
-
step
step attribute.Granularity to be matched by the form control's value.
- Parameters:
value- The new value for this attribute. Can benull to unset the attribute.- Returns:
- This object.
-
type
type attribute.Specifies the type of form control to display.
Common values:
"text" - Single-line text input (default)"password" - Password input (characters are masked)"email" - Email address input with validation"number" - Numeric input with spinner controls"tel" - Telephone number input"url" - URL input with validation"search" - Search input field"date" - Date picker"time" - Time picker"datetime-local" - Date and time picker"checkbox" - Checkbox input"radio" - Radio button input"file" - File upload input"submit" - Submit button"button" - Generic button"reset" - Reset form button"hidden" - Hidden input field
- Parameters:
value- The input type for the form control. Can benull to unset the attribute.- Returns:
- This object.
-
value
value attribute.Value of the form control.
-
width
width attribute.Horizontal dimension.
-