Skip to main content

InputType

Enum InputType 

Source
pub enum InputType {
Show 22 variants Text, Password, Email, Url, Tel, Number, Range, Date, Time, DatetimeLocal, Month, Week, Color, Checkbox, Radio, File, Submit, Reset, Button, Image, Hidden, Search,
}
Expand description

The type attribute values for <input> elements.

§Purpose

Defines the type of input control, determining the behavior, validation, and user interface for collecting user input in forms.

§Usage Context

  • Used with: <input> elements only
  • Default: text if not specified
  • Validation: Many types provide built-in validation (email, url, number)
  • Mobile UX: Types affect virtual keyboard layout on mobile devices

§Valid Values

  • Text: Single-line text input
  • Password: Password input (characters obscured)
  • Email: Email address with validation
  • Url: URL with validation
  • Tel: Telephone number
  • Number: Numeric input with spinner controls
  • Range: Slider control for numeric range
  • Date: Date picker
  • Time: Time picker
  • DatetimeLocal: Date and time picker (no timezone)
  • Month: Month and year picker
  • Week: Week and year picker
  • Color: Color picker
  • Checkbox: Checkbox for boolean values
  • Radio: Radio button for single selection from group
  • File: File upload control
  • Submit: Submit button for forms
  • Reset: Reset button to clear form
  • Button: Generic button (no default behavior)
  • Image: Graphical submit button
  • Hidden: Hidden input (not displayed)
  • Search: Search input with platform-specific styling

§Example

use ironhtml_attributes::{AttributeValue, InputType};
let input_type = InputType::Email;
assert_eq!(input_type.to_attr_value(), "email");
<input type="text" placeholder="Name">
<input type="email" placeholder="user@example.com">
<input type="password" placeholder="Password">
<input type="number" min="0" max="100">
<input type="date">
<input type="checkbox" id="agree">
<input type="submit" value="Submit">

§WHATWG Specification

Variants§

§

Text

Single-line text input. Default type if not specified.

§

Password

Password input where characters are obscured for security.

§

Email

Email address input with built-in validation.

§

Url

URL input with validation for proper URL format.

§

Tel

Telephone number input. Mobile devices show numeric keyboard.

§

Number

Numeric input with optional min, max, and step constraints.

§

Range

Slider control for selecting from a numeric range.

§

Date

Date picker control (year, month, day).

§

Time

Time picker control (hours and minutes).

§

DatetimeLocal

Date and time picker without timezone information.

§

Month

Month and year picker control.

§

Week

Week and year picker control.

§

Color

Color picker returning a hex color value.

§

Checkbox

Checkbox for boolean or multi-selection inputs.

§

Radio

Radio button for single selection from a group.

§

File

File upload control with optional accept and multiple attributes.

§

Submit

Submit button that submits the form.

§

Reset

Reset button that clears the form to default values.

§

Button

Generic button with no default behavior (use with JavaScript).

§

Image

Image-based submit button with click coordinates.

§

Hidden

Hidden input not displayed to users but submitted with form.

§

Search

Search input with platform-specific search styling.

Trait Implementations§

Source§

impl AttributeValue for InputType

Source§

fn to_attr_value(&self) -> Cow<'static, str>

Convert to the attribute value string.
Source§

impl Clone for InputType

Source§

fn clone(&self) -> InputType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for InputType

Source§

impl Debug for InputType

Source§

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

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

impl Eq for InputType

Source§

impl PartialEq for InputType

Source§

fn eq(&self, other: &InputType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for InputType

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.