Skip to main content

FormControlElement

Trait FormControlElement 

Source
pub trait FormControlElement: HtmlElement {
    // Provided methods
    fn disabled(&self) -> bool { ... }
    fn set_disabled(&self, disabled: bool) { ... }
    fn name(&self) -> String { ... }
    fn set_name(&self, name: impl Into<String>) { ... }
    fn form_id(&self) -> Option<String> { ... }
    fn set_form_id(&self, form_id: impl Into<String>) { ... }
    fn required(&self) -> bool { ... }
    fn set_required(&self, required: bool) { ... }
    fn check_validity(&self) -> bool { ... }
}
Expand description

Shared behavior for all form control elements.

Chrome equivalent: HTMLFormControlElement. Every form control (button, input, select, textarea) implements this.

All methods have default implementations that read/write attributes.

Provided Methods§

Source

fn disabled(&self) -> bool

Whether this control is disabled.

Disabled controls don’t receive events and are excluded from form submission. Chrome: HTMLFormControlElement::IsDisabledFormControl().

Source

fn set_disabled(&self, disabled: bool)

Source

fn name(&self) -> String

The control’s name (used as the key in form submission).

Source

fn set_name(&self, name: impl Into<String>)

Source

fn form_id(&self) -> Option<String>

The ID of the associated <form> element.

Chrome: HTMLFormControlElement::formOwner() resolves this to the actual form element. Currently returns the raw attribute; form element resolution will be added with the form submission system.

Source

fn set_form_id(&self, form_id: impl Into<String>)

Source

fn required(&self) -> bool

Whether this control is required for form submission.

Source

fn set_required(&self, required: bool)

Source

fn check_validity(&self) -> bool

Whether this control’s value satisfies its constraints.

Chrome: HTMLFormControlElement::checkValidity(). Future: constraint validation API.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§