Struct html_tags::Input

source ·
pub struct Input<'life> {
Show 65 fields pub accept: Option<AttributeValue<'life>>, pub accesskey: Option<AttributeValue<'life>>, pub alt: Option<AttributeValue<'life>>, pub autocapitalize: Option<AttributeValue<'life>>, pub autocomplete: Option<AttributeValue<'life>>, pub autofocus: Option<AttributeValue<'life>>, pub capture: Option<AttributeValue<'life>>, pub checked: Option<AttributeValue<'life>>, pub class: Option<AttributeValue<'life>>, pub contenteditable: Option<AttributeValue<'life>>, pub contextmenu: Option<AttributeValue<'life>>, pub data: BTreeMap<&'life str, AttributeValue<'life>>, pub dir: Option<AttributeValue<'life>>, pub dirname: Option<AttributeValue<'life>>, pub disabled: Option<AttributeValue<'life>>, pub draggable: Option<AttributeValue<'life>>, pub enterkeyhint: Option<AttributeValue<'life>>, pub exportparts: Option<AttributeValue<'life>>, pub extra: BTreeMap<&'life str, AttributeValue<'life>>, pub form: Option<AttributeValue<'life>>, pub formaction: Option<AttributeValue<'life>>, pub formenctype: Option<AttributeValue<'life>>, pub formmethod: Option<AttributeValue<'life>>, pub formnovalidate: Option<AttributeValue<'life>>, pub formtarget: Option<AttributeValue<'life>>, pub height: Option<AttributeValue<'life>>, pub hidden: Option<AttributeValue<'life>>, pub id: Option<AttributeValue<'life>>, pub inert: Option<AttributeValue<'life>>, pub inputmode: Option<AttributeValue<'life>>, pub is: Option<AttributeValue<'life>>, pub itemid: Option<AttributeValue<'life>>, pub itemprop: Option<AttributeValue<'life>>, pub itemref: Option<AttributeValue<'life>>, pub itemscope: Option<AttributeValue<'life>>, pub itemtype: Option<AttributeValue<'life>>, pub lang: Option<AttributeValue<'life>>, pub list: Option<AttributeValue<'life>>, pub max: Option<AttributeValue<'life>>, pub maxlength: Option<AttributeValue<'life>>, pub min: Option<AttributeValue<'life>>, pub minlength: Option<AttributeValue<'life>>, pub multiple: Option<AttributeValue<'life>>, pub name: Option<AttributeValue<'life>>, pub nonce: Option<AttributeValue<'life>>, pub part: Option<AttributeValue<'life>>, pub pattern: Option<AttributeValue<'life>>, pub placeholder: Option<AttributeValue<'life>>, pub popover: Option<AttributeValue<'life>>, pub readonly: Option<AttributeValue<'life>>, pub required: Option<AttributeValue<'life>>, pub role: Option<AttributeValue<'life>>, pub size: Option<AttributeValue<'life>>, pub slot: Option<AttributeValue<'life>>, pub spellcheck: Option<AttributeValue<'life>>, pub src: Option<AttributeValue<'life>>, pub step: Option<AttributeValue<'life>>, pub style: Option<AttributeValue<'life>>, pub tabindex: Option<AttributeValue<'life>>, pub title: Option<AttributeValue<'life>>, pub translate: Option<AttributeValue<'life>>, pub type_: Option<AttributeValue<'life>>, pub value: Option<AttributeValue<'life>>, pub virtualkeyboardpolicy: Option<AttributeValue<'life>>, pub width: Option<AttributeValue<'life>>,
}
Expand description

The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

More information: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

Fields§

§accept: Option<AttributeValue<'life>>

Valid for the file input type only, the accept attribute defines which file types are selectable in a file upload control. See the file input type.

§accesskey: Option<AttributeValue<'life>>

Provides a hint for generating a keyboard shortcut for the current element. This attribute consists of a space-separated list of characters. The browser should use the first one that exists on the computer keyboard layout.

§alt: Option<AttributeValue<'life>>

Valid for the image button only, the alt attribute provides alternative text for the image, displaying the value of the attribute if the image src is missing or otherwise fails to load. See the image input type.

§autocapitalize: Option<AttributeValue<'life>>

Controls whether and how text input is automatically capitalized as it is entered/edited by the user. It can have the following values:

  • off or none, no autocapitalization is applied (all letters default to lowercase)
  • on or sentences, the first letter of each sentence defaults to a capital letter; all other letters default to lowercase
  • words, the first letter of each word defaults to a capital letter; all other letters default to lowercase
  • characters, all letters should default to uppercase
§autocomplete: Option<AttributeValue<'life>>

(Not a Boolean attribute!) The autocomplete attribute takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. A typical implementation of autocomplete recalls previous values entered in the same input field, but more complex forms of autocomplete can exist. For instance, a browser could integrate with a device's contacts list to autocomplete email addresses in an email input field. See autocomplete for permitted values.

The autocomplete attribute is valid on hidden, text, search, url, tel, email, date, month, week, time, datetime-local, number, range, color, and password. This attribute has no effect on input types that do not return numeric or text data, being valid for all input types except checkbox, radio, file, or any of the button types.

See the autocomplete attribute for additional information, including information on password security and how autocomplete is slightly different for hidden than for other input types.

§autofocus: Option<AttributeValue<'life>>

A Boolean attribute which, if present, indicates that the input should automatically have focus when the page has finished loading (or when the <dialog> containing the element has been displayed).

Note: An element with the autofocus attribute may gain focus before the DOMContentLoaded event is fired.

No more than one element in the document may have the autofocus attribute. If put on more than one element, the first one with the attribute receives focus.

The autofocus attribute cannot be used on inputs of type hidden, since hidden inputs cannot be focused.

Warning: Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.

Use careful consideration for accessibility when applying the autofocus attribute. Automatically focusing on a control can cause the page to scroll on load. The focus can also cause dynamic keyboards to display on some touch devices. While a screen reader will announce the label of the form control receiving focus, the screen reader will not announce anything before the label, and the sighted user on a small device will equally miss the context created by the preceding content.

§capture: Option<AttributeValue<'life>>

Introduced in the HTML Media Capture specification and valid for the file input type only, the capture attribute defines which media—microphone, video, or camera—should be used to capture a new file for upload with file upload control in supporting scenarios. See the file input type.

§checked: Option<AttributeValue<'life>>

Valid for both radio and checkbox types, checked is a Boolean attribute. If present on a radio type, it indicates that the radio button is the currently selected one in the group of same-named radio buttons. If present on a checkbox type, it indicates that the checkbox is checked by default (when the page loads). It does not indicate whether this checkbox is currently checked: if the checkbox's state is changed, this content attribute does not reflect the change. (Only the HTMLInputElement's checked IDL attribute is updated.)

Note: Unlike other input controls, a checkboxes and radio buttons value are only included in the submitted data if they are currently checked. If they are, the name and the value(s) of the checked controls are submitted.

For example, if a checkbox whose name is fruit has a value of cherry, and the checkbox is checked, the form data submitted will include fruit=cherry. If the checkbox isn't active, it isn't listed in the form data at all. The default value for checkboxes and radio buttons is on.

§class: Option<AttributeValue<'life>>

A space-separated list of the classes of the element. Classes allow CSS and JavaScript to select and access specific elements via the class selectors or functions like the method Document.getElementsByClassName().

§contenteditable: Option<AttributeValue<'life>>

An enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing. The attribute must take one of the following values:

  • true or the empty string, which indicates that the element must be editable;
  • false, which indicates that the element must not be editable.
§contextmenu: Option<AttributeValue<'life>>

The id of a <menu> to use as the contextual menu for this element.

§data: BTreeMap<&'life str, AttributeValue<'life>>

Forms a class of attributes, called custom data attributes, that allow proprietary information to be exchanged between the HTML and its DOM representation that may be used by scripts. All such custom data are available via the HTMLElement interface of the element the attribute is set on. The HTMLElement.dataset property gives access to them.

§dir: Option<AttributeValue<'life>>

An enumerated attribute indicating the directionality of the element's text. It can have the following values:

  • ltr, which means left to right and is to be used for languages that are written from the left to the right (like English);
  • rtl, which means right to left and is to be used for languages that are written from the right to the left (like Arabic);
  • auto, which lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then it applies that directionality to the whole element.
§dirname: Option<AttributeValue<'life>>
<p>Valid for <code>text</code> and <code>search</code> input types only, the <code>dirname</code> attribute enables the submission of the directionality of the element. When included, the form control will submit with two name/value pairs: the first being the <a href="#name"><code>name</code></a> and <a href="#value"><code>value</code></a>, the second being the value of the <code>dirname</code> as the name with the value of <code>ltr</code> or <code>rtl</code> being set by the browser.</p>
<div class="code-example"><pre class="brush: html notranslate"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span> <span class="token attr-name">action</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>page.html<span class="token punctuation">"</span></span> <span class="token attr-name">method</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>post<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>

<label >Fruit: <input type=text name=fruit dirname=fruit.dir value=cherry /> </label> <input type=submit /> </form> <!– page.html?fruit=cherry&fruit.dir=ltr –>

When the form above is submitted, the input cause both the name / value pair of fruit=cherry and the dirname / direction pair of fruit.dir=ltr to be sent.

§disabled: Option<AttributeValue<'life>>

A Boolean attribute which, if present, indicates that the user should not be able to interact with the input. Disabled inputs are typically rendered with a dimmer color or using some other form of indication that the field is not available for use.

Specifically, disabled inputs do not receive the click event, and disabled inputs are not submitted with the form.

Note: Although not required by the specification, Firefox will by default persist the dynamic disabled state of an <input> across page loads. Use the autocomplete attribute to control this feature.

§draggable: Option<AttributeValue<'life>>

An enumerated attribute indicating whether the element can be dragged, using the Drag and Drop API. It can have the following values:

  • true, which indicates that the element may be dragged
  • false, which indicates that the element may not be dragged.
§enterkeyhint: Option<AttributeValue<'life>>

Hints what action label (or icon) to present for the enter key on virtual keyboards.

§exportparts: Option<AttributeValue<'life>>

Used to transitively export shadow parts from a nested shadow tree into a containing light tree.

§extra: BTreeMap<&'life str, AttributeValue<'life>>

/// Extra attributes of the element. This is a map of attribute names to their values, and the attribute names are in lowercase.

§form: Option<AttributeValue<'life>>

A string specifying the <form> element with which the input is associated (that is, its form owner). This string's value, if present, must match the id of a <form> element in the same document. If this attribute isn't specified, the <input> element is associated with the nearest containing form, if any.

The form attribute lets you place an input anywhere in the document but have it included with a form elsewhere in the document.

Note: An input can only be associated with one form.

§formaction: Option<AttributeValue<'life>>

Valid for the image and submit input types only. See the submit input type for more information.

§formenctype: Option<AttributeValue<'life>>

Valid for the image and submit input types only. See the submit input type for more information.

§formmethod: Option<AttributeValue<'life>>

Valid for the image and submit input types only. See the submit input type for more information.

§formnovalidate: Option<AttributeValue<'life>>

Valid for the image and submit input types only. See the submit input type for more information.

§formtarget: Option<AttributeValue<'life>>

Valid for the image and submit input types only. See the submit input type for more information.

§height: Option<AttributeValue<'life>>

Valid for the image input button only, the height is the height of the image file to display to represent the graphical submit button. See the image input type.

§hidden: Option<AttributeValue<'life>>

An enumerated attribute indicating that the element is not yet, or is no longer, relevant. For example, it can be used to hide elements of the page that can't be used until the login process has been completed. The browser won't render such elements. This attribute must not be used to hide content that could legitimately be shown.

§id: Option<AttributeValue<'life>>

Global attribute valid for all elements, including all the input types, it defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking. The value is used as the value of the <label>'s for attribute to link the label with the form control. See <label>.

§inert: Option<AttributeValue<'life>>

A boolean value that makes the browser disregard user input events for the element. Useful when click events are present.

§inputmode: Option<AttributeValue<'life>>

Global value valid for all elements, it provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. Values include none, text, tel, url, email, numeric, decimal, and search.

§is: Option<AttributeValue<'life>>

Allows you to specify that a standard HTML element should behave like a registered custom built-in element (see Using custom elements for more details).

§itemid: Option<AttributeValue<'life>>

The unique, global identifier of an item.

§itemprop: Option<AttributeValue<'life>>

Used to add properties to an item. Every HTML element may have an itemprop attribute specified, where an itemprop consists of a name and value pair.

§itemref: Option<AttributeValue<'life>>

Properties that are not descendants of an element with the itemscope attribute can be associated with the item using an itemref. It provides a list of element ids (not itemids) with additional properties elsewhere in the document.

§itemscope: Option<AttributeValue<'life>>

itemscope (usually) works along with itemtype to specify that the HTML contained in a block is about a particular item. itemscope creates the Item and defines the scope of the itemtype associated with it. itemtype is a valid URL of a vocabulary (such as schema.org) that describes the item and its properties context.

§itemtype: Option<AttributeValue<'life>>

Specifies the URL of the vocabulary that will be used to define itemprops (item properties) in the data structure. itemscope is used to set the scope of where in the data structure the vocabulary set by itemtype will be active.

§lang: Option<AttributeValue<'life>>

Helps define the language of an element: the language that non-editable elements are in, or the language that editable elements should be written in by the user. The attribute contains one "language tag" (made of hyphen-separated "language subtags") in the format defined in RFC 5646: Tags for Identifying Languages (also known as BCP 47). xml:lang has priority over it.

§list: Option<AttributeValue<'life>>

The value given to the list attribute should be the id of a <datalist> element located in the same document. The <datalist> provides a list of predefined values to suggest to the user for this input. Any values in the list that are not compatible with the type are not included in the suggested options. The values provided are suggestions, not requirements: users can select from this predefined list or provide a different value.

It is valid on text, search, url, tel, email, date, month, week, time, datetime-local, number, range, and color.

Per the specifications, the list attribute is not supported by the hidden, password, checkbox, radio, file, or any of the button types.

Depending on the browser, the user may see a custom color palette suggested, tic marks along a range, or even an input that opens like a <select> but allows for non-listed values. Check out the browser compatibility table for the other input types.

See the <datalist> element.

§max: Option<AttributeValue<'life>>

Valid for date, month, week, time, datetime-local, number, and range, it defines the greatest value in the range of permitted values. If the value entered into the element exceeds this, the element fails constraint validation. If the value of the max attribute isn't a number, then the element has no maximum value.

There is a special case: if the data type is periodic (such as for dates or times), the value of max may be lower than the value of min, which indicates that the range may wrap around; for example, this allows you to specify a time range from 10 PM to 4 AM.

§maxlength: Option<AttributeValue<'life>>

Valid for text, search, url, tel, email, and password, it defines the maximum number of characters (as UTF-16 code units) the user can enter into the field. This must be an integer value 0 or higher. If no maxlength is specified, or an invalid value is specified, the field has no maximum length. This value must also be greater than or equal to the value of minlength.

The input will fail constraint validation if the length of the text entered into the field is greater than maxlength UTF-16 code units long. By default, browsers prevent users from entering more characters than allowed by the maxlength attribute. See Client-side validation for more information.

§min: Option<AttributeValue<'life>>

Valid for date, month, week, time, datetime-local, number, and range, it defines the most negative value in the range of permitted values. If the value entered into the element is less than this, the element fails constraint validation. If the value of the min attribute isn't a number, then the element has no minimum value.

This value must be less than or equal to the value of the max attribute. If the min attribute is present but is not specified or is invalid, no min value is applied. If the min attribute is valid and a non-empty value is less than the minimum allowed by the min attribute, constraint validation will prevent form submission. See Client-side validation for more information.

There is a special case: if the data type is periodic (such as for dates or times), the value of max may be lower than the value of min, which indicates that the range may wrap around; for example, this allows you to specify a time range from 10 PM to 4 AM.

§minlength: Option<AttributeValue<'life>>

Valid for text, search, url, tel, email, and password, it defines the minimum number of characters (as UTF-16 code units) the user can enter into the entry field. This must be a non-negative integer value smaller than or equal to the value specified by maxlength. If no minlength is specified, or an invalid value is specified, the input has no minimum length.

The input will fail constraint validation if the length of the text entered into the field is fewer than minlength UTF-16 code units long, preventing form submission. See Client-side validation for more information.

§multiple: Option<AttributeValue<'life>>

The Boolean multiple attribute, if set, means the user can enter comma separated email addresses in the email widget or can choose more than one file with the file input. See the email and file input type.

§name: Option<AttributeValue<'life>>
<p>A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted.</p>
<p>Consider the <code>name</code> a required attribute (even though it's not). If an input has no <code>name</code> specified, or <code>name</code> is empty, the input's value is not submitted with the form! (Disabled controls, unchecked radio buttons, unchecked checkboxes, and reset buttons are also not sent.)</p>
<p>There are two special cases:</p>
<ol>
  <li><code>_charset_</code> : If used as the name of an <code>&lt;input&gt;</code> element of type <a href="/en-US/docs/Web/HTML/Element/input/hidden">hidden</a>, the input's <code>value</code> is automatically set by the <a href="/en-US/docs/Glossary/User_agent">user agent</a> to the character encoding being used to submit the form.</li>
  <li><code>isindex</code>: For historical reasons, the name <a class="external" target="_blank" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-name"><code>isindex</code></a> is not allowed.</li>
</ol>
<p>The <a href="#name"><code>name</code></a> attribute creates a unique behavior for radio buttons.</p>
<p>Only one radio button in a same-named group of radio buttons can be checked at a time. Selecting any radio button in that group automatically deselects any currently-selected radio button in the same group. The value of that one checked radio button is sent along with the name if the form is submitted,</p>
<p>When tabbing into a series of same-named group of radio buttons, if one is checked, that one will receive focus. If they aren't grouped together in source order, if one of the group is checked, tabbing into the group starts when the first one in the group is encountered, skipping all those that aren't checked. In other words, if one is checked, tabbing skips the unchecked radio buttons in the group. If none are checked, the radio button group receives focus when the first button in the same name group is reached.</p>
<p>Once one of the radio buttons in a group has focus, using the arrow keys will navigate through all the radio buttons of the same name, even if the radio buttons are not grouped together in the source order.</p>
<p>When an input element is given a <code>name</code>, that name becomes a property of the owning form element's <a href="/en-US/docs/Web/API/HTMLFormElement/elements"><code>HTMLFormElement.elements</code></a> property. If you have an input whose <code>name</code> is set to <code>guest</code> and another whose <code>name</code> is <code>hat-size</code>, the following code can be used:</p>
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">let</span> form <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">querySelector</span><span class="token punctuation">(</span><span class="token string">"form"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

let guestName = form.elements.guest; let hatSize = form.elements[“hat-size”];

When this code has run, guestName will be the HTMLInputElement for the guest field, and hatSize the object for the hat-size field.

Warning: Avoid giving form elements a name that corresponds to a built-in property of the form, since you would then override the predefined property or method with this reference to the corresponding input.

§nonce: Option<AttributeValue<'life>>

A cryptographic nonce ("number used once") which can be used by Content Security Policy to determine whether or not a given fetch will be allowed to proceed.

§part: Option<AttributeValue<'life>>

A space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element.

§pattern: Option<AttributeValue<'life>>

Valid for text, search, url, tel, email, and password, the pattern attribute defines a regular expression that the input's value must match in order for the value to pass constraint validation. It must be a valid JavaScript regular expression, as used by the RegExp type, and as documented in our guide on regular expressions; the 'u' flag is specified when compiling the regular expression, so that the pattern is treated as a sequence of Unicode code points, instead of as ASCII. No forward slashes should be specified around the pattern text.

If the pattern attribute is present but is not specified or is invalid, no regular expression is applied and this attribute is ignored completely. If the pattern attribute is valid and a non-empty value does not match the pattern, constraint validation will prevent form submission.

Note: If using the pattern attribute, inform the user about the expected format by including explanatory text nearby. You can also include a title attribute to explain what the requirements are to match the pattern; most browsers will display this title as a tooltip. The visible explanation is required for accessibility. The tooltip is an enhancement.

See Client-side validation for more information.

§placeholder: Option<AttributeValue<'life>>

Valid for text, search, url, tel, email, password, and number, the placeholder attribute provides a brief hint to the user as to what kind of information is expected in the field. It should be a word or short phrase that provides a hint as to the expected type of data, rather than an explanation or prompt. The text must not include carriage returns or line feeds. So for example if a field is expected to capture a user's first name, and its label is "First Name", a suitable placeholder might be "e.g. Mustafa".

Note: The placeholder attribute is not as semantically useful as other ways to explain your form, and can cause unexpected technical issues with your content. See Labels for more information.

§popover: Option<AttributeValue<'life>>

Specifies that the element should be treated like a popover. An element with the popover attribute is hidden from the page unless it is opened by interacting with an invoking element that has popovertarget, or via showPopover().

§readonly: Option<AttributeValue<'life>>

A Boolean attribute which, if present, indicates that the user should not be able to edit the value of the input. The readonly attribute is supported by the text, search, url, tel, email, date, month, week, time, datetime-local, number, and password input types.

See the HTML attribute: readonly for more information.

§required: Option<AttributeValue<'life>>

required is a Boolean attribute which, if present, indicates that the user must specify a value for the input before the owning form can be submitted. The required attribute is supported by text, search, url, tel, email, date, month, week, time, datetime-local, number, password, checkbox, radio, and file inputs.

See Client-side validation and the HTML attribute: required for more information.

§role: Option<AttributeValue<'life>>

Roles define the semantic meaning of content, allowing screen readers and other tools to present and support interaction with an object in a way that is consistent with user expectations of that type of object. roles are added to HTML elements using role="role_type", where role_type is the name of a role in the ARIA specification.

§size: Option<AttributeValue<'life>>

Valid for email, password, tel, url, and text, the size attribute specifies how much of the input is shown. Basically creates same result as setting CSS width property with a few specialities. The actual unit of the value depends on the input type. For password and text, it is a number of characters (or em units) with a default value of 20, and for others, it is pixels (or px units). CSS width takes precedence over the size attribute.

§slot: Option<AttributeValue<'life>>

Assigns a slot in a shadow DOM shadow tree to an element: An element with a slot attribute is assigned to the slot created by the <slot> element whose name attribute's value matches that slot attribute's value.

§spellcheck: Option<AttributeValue<'life>>

An enumerated attribute defines whether the element may be checked for spelling errors. It may have the following values:

§src: Option<AttributeValue<'life>>

Valid for the image input button only, the src is string specifying the URL of the image file to display to represent the graphical submit button. See the image input type.

§step: Option<AttributeValue<'life>>

Valid for date, month, week, time, datetime-local, number, and range, the step attribute is a number that specifies the granularity that the value must adhere to.

If not explicitly included:

The value must be a positive number—integer or float—or the special value any, which means no stepping is implied, and any value is allowed (barring other constraints, such as min and max).

If any is not explicitly set, valid values for the number, date/time input types, and range input types are equal to the basis for stepping — the min value and increments of the step value, up to the max value, if specified.

For example, if you have <input type="number" min="10" step="2">, then any even integer, 10 or greater, is valid. If omitted, <input type="number">, any integer is valid, but floats (like 4.2) are not valid, because step defaults to 1. For 4.2 to be valid, step would have had to be set to any, 0.1, 0.2, or any the min value would have had to be a number ending in .2, such as <input type="number" min="-5.2">

Note: When the data entered by the user doesn't adhere to the stepping configuration, the value is considered invalid in constraint validation and will match the :invalid pseudoclass.

See Client-side validation for more information.

§style: Option<AttributeValue<'life>>

Contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes.

§tabindex: Option<AttributeValue<'life>>

Global attribute valid for all elements, including all the input types, an integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. As all input types except for input of type hidden are focusable, this attribute should not be used on form controls, because doing so would require the management of the focus order for all elements within the document with the risk of harming usability and accessibility if done incorrectly.

§title: Option<AttributeValue<'life>>

Global attribute valid for all elements, including all input types, containing a text representing advisory information related to the element it belongs to. Such information can typically, but not necessarily, be presented to the user as a tooltip. The title should NOT be used as the primary explanation of the purpose of the form control. Instead, use the <label> element with a for attribute set to the form control's id attribute. See Labels below.

§translate: Option<AttributeValue<'life>>

An enumerated attribute that is used to specify whether an element's attribute values and the values of its Text node children are to be translated when the page is localized, or whether to leave them unchanged. It can have the following values:

§type_: Option<AttributeValue<'life>>

A string specifying the type of control to render. For example, to create a checkbox, a value of checkbox is used. If omitted (or an unknown value is specified), the input type text is used, creating a plaintext input field.

Permitted values are listed in Input types above.

§value: Option<AttributeValue<'life>>

The input control's value. When specified in the HTML, this is the initial value, and from then on it can be altered or retrieved at any time using JavaScript to access the respective HTMLInputElement object's value property. The value attribute is always optional, though should be considered mandatory for checkbox, radio, and hidden.

§virtualkeyboardpolicy: Option<AttributeValue<'life>>

An enumerated attribute used to control the on-screen virtual keyboard behavior on devices such as tablets, mobile phones, or other devices where a hardware keyboard may not be available for elements that also uses the contenteditable attribute.

§width: Option<AttributeValue<'life>>

Valid for the image input button only, the width is the width of the image file to display to represent the graphical submit button. See the image input type.

Implementations§

source§

impl<'life> Input<'life>

source

pub fn tag() -> &'static str

Get the tag name of the element. This is the same as the name of the struct, in kebab-case.

source

pub fn set_attr( &mut self, name: &'life str, value: impl Into<AttributeValue<'life>> )

Sets an attribute of the element. This sets the attribute of the struct. If the attribute is not a known attribute, it is added to the extra map. If the alloc feature is disabled, this function will silently fail.

Note

This only works when the attribute is lowercase.

Trait Implementations§

source§

impl<'life> Clone for Input<'life>

source§

fn clone(&self) -> Input<'life>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'life> Debug for Input<'life>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'life> Default for Input<'life>

source§

fn default() -> Input<'life>

Returns the “default value” for a type. Read more
source§

impl<'life> Ord for Input<'life>

source§

fn cmp(&self, other: &Input<'life>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<'life> PartialEq<Input<'life>> for Input<'life>

source§

fn eq(&self, other: &Input<'life>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'life> PartialOrd<Input<'life>> for Input<'life>

source§

fn partial_cmp(&self, other: &Input<'life>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'life> Eq for Input<'life>

source§

impl<'life> StructuralEq for Input<'life>

source§

impl<'life> StructuralPartialEq for Input<'life>

Auto Trait Implementations§

§

impl<'life> RefUnwindSafe for Input<'life>

§

impl<'life> Send for Input<'life>

§

impl<'life> Sync for Input<'life>

§

impl<'life> Unpin for Input<'life>

§

impl<'life> UnwindSafe for Input<'life>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.