HTMLFormElement

HTMLFormElement

Overview

HTMLFormElement is a class in Aspose.Html FOSS for Python. Inherits from: HTMLElement.

HTML <form> element.

This class provides 85 methods for working with HTMLFormElement objects in Python programs. Available methods include: __init__, add_event_listener, after, append, append_child, attach_shadow, before, blur, check_validity, check_visibility, click, clone_node, and 73 additional methods. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: accept_charset, access_key, access_key_label, action, assigned_slot, attributes, and 79 more.

Properties

NameTypeAccessDescription
actionstrRead/WriteThe action attribute value, or '' when absent.
methodstrRead/WriteThe method attribute value; returns 'get' when absent (WHATWG default).
namestrRead/WriteThe name attribute value, or '' when absent.
enctypestrRead/WriteThe enctype attribute (encoding type); default
    ``"application/x-www-form-urlencoded"`` when absent (WHATWG §4.10.3). |

| rel | str | Read/Write | The rel attribute value, or '' when absent. | | encoding | str | Read/Write | IDL alias for :attr:enctype per WHATWG §4.10.3. | | novalidate | bool | Read/Write | Boolean presence attribute reflecting the HTML novalidate attribute. | | target | str | Read/Write | The target attribute value, or '' when absent. | | autocomplete | str | Read/Write | The autocomplete attribute value; default "on" when absent (WHATWG §4.10.3). | | elements | "_SubtreeHTMLCollection" | Read | Live collection of all form-associated controls in tree order. | | length | int | Read | Number of listed form-control elements (WHATWG HTML §4.10.3). | | no_validate | bool | Read/Write | Boolean presence attribute reflecting the HTML novalidate attribute. | | accept_charset | str | Read/Write | The accept-charset attribute value, or '' when absent. | | auto_complete | str | Read/Write | The autocomplete attribute value, or '' when absent. | | rel_list | "DOMTokenList" | Read | DOMTokenList backed by the rel attribute (WHATWG HTML §4.10.3). | | hidden | bool | Read/Write | Whether the element is hidden (reflects the hidden boolean attribute). | | title | str | Read/Write | The tooltip title of this element (reflects the title attribute). | | lang | str | Read/Write | The language of the element’s content (reflects the lang attribute). | | tab_index | int | Read/Write | The tab order index of this element (reflects the tabindex attribute). | | access_key | str | Read/Write | The keyboard shortcut key for this element (reflects the accesskey

    attribute). |

| content_editable | str | Read/Write | Reflects the contenteditable attribute (WHATWG HTML §6.6). | | is_content_editable | bool | Read | Whether this element is currently editable (WHATWG HTML §6.6). | | dir | str | Read/Write | Text directionality of the element (reflects the dir attribute). | | draggable | bool | Read/Write | Whether the element is draggable (reflects the draggable attribute). | | spell_check | bool | Read/Write | Whether spellchecking is enabled (reflects the spellcheck attribute). | | spellcheck | bool | Read/Write | Whether spellchecking is enabled (reflects the spellcheck attribute). | | autocapitalize | str | Read/Write | Auto-capitalisation hint (reflects the autocapitalize attribute). | | nonce | str | Read/Write | Cryptographic nonce for CSP (reflects the nonce attribute). | | autofocus | bool | Read/Write | Whether this element should receive focus on page load. | | access_key_label | str | Read | System-assigned access key label (headless stub: always ''). | | input_mode | str | Read/Write | Virtual keyboard input mode hint (reflects the inputmode attribute). | | enter_key_hint | str | Read/Write | Enter-key action label hint (reflects the enterkeyhint attribute). | | translate | bool | Read/Write | Whether translation is enabled for this element (WHATWG HTML §6.1.2). | | inner_text | str | Read/Write | Rendered text content — whitespace-collapsed text_content. | | outer_text | str | Read/Write | Same as inner_text (getter mirrors inner_text per HTML Standard §3.2.7). | | popover | | Read/Write | Reflects thepopovercontent attribute (WHATWG HTML §6.12). | | `node_name` | `str` | Read | The qualified tag name (uppercase for HTML elements). | | `tag_name` | `str` | Read | The qualified tag name in uppercase (HTML elements). | | `local_name` | `str` | Read | The local part of the qualified name (lowercase). | | `namespace_uri` | `str \| None` | Read | The namespace URI, orNonefor no namespace. | | `style_sheets` | `"StyleSheetList"` | Read | Live stylesheet list applicable to this element's document. | | `prefix` | `str \| None` | Read | The namespace prefix, orNone. | | `id` | `str` | Read | The value of the idattribute, or’’if not present. | | `class_name` | `str` | Read | The value of theclassattribute, or’’. | | `class_list` | `"DOMTokenList"` | Read | Live mutable set of CSS class tokens backed by the classattribute. | | `dataset` | `"DOMStringMap"` | Read | Live dict-like view of the element'sdata-*custom attributes. | | `attributes` | `NamedNodeMap` | Read | The ordered map of Attr objects for this element. | | `children` | `HTMLCollection` | Read | A live HTMLCollection of Element-type children only. | | `first_element_child` | `Element \| None` | Read | The first Element child, orNone. | | `last_element_child` | `Element \| None` | Read | The last Element child, or None. | | `next_element_sibling` | `Element \| None` | Read | The next sibling that is an Element, or None. | | `previous_element_sibling` | `Element \| None` | Read | The previous sibling that is an Element, or None. | | `child_element_count` | `int` | Read | The number of Element children. | | `inner_html` | `str` | Read/Write | The serialised HTML content of all children (innerHTML). | | `outer_html` | `str` | Read/Write | The serialised HTML of this element and all its descendants (outerHTML). | | `text_content` | `str \| None` | Read/Write | The concatenation of all descendant Text node data (DFS order). | | `style` | `"CSSStyleDeclaration"` | Read | The inline style of this element as a live CSSStyleDeclaration. | | `scroll_width` | `int` | Read | Content scroll width in CSS pixels (stub: 0). | | `scroll_height` | `int` | Read | Content scroll height in CSS pixels (stub: 0). | | `client_width` | `int` | Read | Inner width including padding, excluding border (stub: 0). | | `client_height` | `int` | Read | Inner height including padding, excluding border (stub: 0). | | `scroll_top` | `int` | Read/Write | Vertical scroll offset in CSS pixels (stub: 0). | | `scroll_left` | `int` | Read/Write | Horizontal scroll offset in CSS pixels (stub: 0). | | `offset_width` | `int` | Read | Layout border-box width in CSS pixels (stub: 0). | | `offset_height` | `int` | Read | Layout border-box height in CSS pixels (stub: 0). | | `offset_top` | `int` | Read | Top offset from offsetParentin CSS pixels (stub: 0). | | `offset_left` | `int` | Read | Left offset fromoffsetParentin CSS pixels (stub: 0). | | `offset_parent` | `None` | Read | The offset parent element; alwaysNonein headless mode. | | `client_top` | `int` | Read | Width of the top CSS border in pixels; always0in headless mode. | | `client_left` | `int` | Read | Width of the left CSS border in pixels; always0in headless mode. | | `part` | `"DOMTokenList"` | Read | Live DOMTokenList reflecting the elementpartattribute. | | `shadow_root` | | Read | Always None in headless mode. | | slot | str | Read/Write | Reflects the slot content attribute (DOM §4.2.3). | | assigned_slot | | Read | AlwaysNonein headless mode. | | `node_type` | `int` | Read | Integer node type constant fromNodeType. | | `node_value` | `str \| None` | Read/Write | Character data for CharacterData nodes; Noneotherwise. | | `parent_node` | `Node \| None` | Read | The parent node, orNoneif this node has no parent. | | `parent_element` | `Element \| None` | Read | The parent node if it is an Element;Noneotherwise. | | `is_connected` | `bool` | Read | Whether this node is part of a document's node tree (WHATWG DOM §4.4). | | `owner_document` | `Document \| None` | Read | The Document this node belongs to, orNonefor Document itself. | | `child_nodes` | `NodeList` | Read | A live NodeList of all child nodes. | | `first_child` | `Node \| None` | Read | The first child node, orNone. | | `last_child` | `Node \| None` | Read | The last child node, or None. | | `previous_sibling` | `Node \| None` | Read | The preceding sibling node, or None. | | `next_sibling` | `Node \| None` | Read | The following sibling node, or None``. |

Methods

SignatureDescription
submit()Submit the form (not supported in headless mode).
reset()Reset the form (not supported in headless mode).
request_submit(submitter: object)Request form submission (not supported in headless mode).
check_validity()boolReturn True if all listed and validatable form controls are valid.
report_validity()boolReturn True if all listed form controls are valid (headless mode).
item(index: int)objectReturn the listed form-control element at index, or None.
named_item(name: str)objectReturn the first listed form-control element with id or name
    equal to *name*, or ``None`` if none found. |

| click() | Dispatch a synthetic click event on this element. | | focus(options: "dict \| None") | Dispatch a non-bubbling 'focus' event on this element. | | blur() | Dispatch a non-bubbling 'blur' event on this element. | | show_popover() | Show this element as a popover (no-op in headless mode). | | hide_popover() | Hide this element’s popover (no-op in headless mode). | | toggle_popover(force: "bool \| None")bool | Toggle this element’s popover state (no-op, always returns False). | | __init__(local_name: str, namespace_uri: str \| None, prefix: str \| None, owner_document: Document \| None) | Calls init(local_name, namespace_uri, prefix, owner_document) on this HTMLFormElement instance. | | get_computed_style()"ComputedStyleDeclaration" | Return phase-2 cascade-resolved declarations for this element. | | insert_adjacent_html(position: str, html: str) | Insert parsed HTML markup relative to this element. | | insert_adjacent_text(position: str, text: str) | Insert a text node relative to this element. | | insert_adjacent_element(position: str, element: "Element \| None")"Element \| None" | Insert element at position relative to this element. | | get_attribute(name: str)str \| None | Return the value of attribute name, or None if absent. | | set_attribute(name: str, value: str) | Set attribute name to value, creating it if not present. | | remove_attribute(name: str) | Remove attribute name. | | has_attribute(name: str)bool | Return True if attribute name exists on this element. | | get_attribute_node(name: str)"Attr \| None" | Return the Attr object for attribute name, or None if absent. | | set_attribute_node(attr: "Attr")"Attr \| None" | Insert or replace attr in this element’s attribute set. | | remove_attribute_node(attr: "Attr")"Attr" | Remove attr from this element’s attribute set and return it. | | get_attribute_node_ns(namespace_uri: str \| None, local_name: str)"Attr \| None" | Return the Attr node matching namespace_uri and local_name, or None. | | set_attribute_node_ns(attr: "Attr")"Attr \| None" | Insert or replace a namespaced Attr node. | | remove_attribute_node_ns(namespace_uri: str \| None, local_name: str)"Attr" | Remove and return the Attr node matching namespace_uri and local_name. | | get_attribute_ns(namespace_uri: str \| None, local_name: str)str \| None | Return the value of the namespaced attribute, or None if absent. | | set_attribute_ns(namespace_uri: str \| None, qualified_name: str, value: str) | Set a namespaced attribute to value, creating it if not present. | | has_attribute_ns(namespace_uri: str \| None, local_name: str)bool | Return True if a namespaced attribute with the given local name exists. | | remove_attribute_ns(namespace_uri: str \| None, local_name: str) | Remove the namespaced attribute. | | toggle_attribute(name: str, force: bool \| None)bool | Toggle attribute name and return its new presence state. | | get_attribute_names()list[str] | Return the qualified names of all attributes in collection order. | | has_attributes()bool | Return True when this element has one or more attributes. | | scroll_into_view(arg: bool \| dict \| None) | Scroll this element into view (no-op in server-side context). | | scroll(x_or_options: float \| dict \| None, y: float \| None) | Scroll this element to coordinates (no-op in server-side context). | | scroll_into_view_if_needed(center_if_needed: bool) | Scroll this element into view if it is not already visible (no-op in headless mode). | | set_pointer_capture(pointer_id: int) | Designate this element as the capture target for the given pointer (no-op). | | release_pointer_capture(pointer_id: int) | Release pointer capture for the given pointer id (no-op). | | has_pointer_capture(pointer_id: int)bool | Return whether this element has pointer capture for the given id. | | request_pointer_lock() | Request that the pointer be locked to this element (no-op). | | request_fullscreen(options: "dict \| None") | Request that this element be displayed in fullscreen mode (no-op). | | check_visibility(options: "dict \| None")bool | Return whether this element is visible in the current rendering (always True). | | query_selector(selector: str)Element \| None | Return the first element in the subtree matching selector. | | query_selector_all(selector: str)NodeList | Return a static NodeList of all elements matching selector. | | matches(selector: str)bool | Return True if this element matches the CSS selector. | | webkit_matches_selector(selector: str)bool | Browser-compat alias for :meth:matches. | | closest(selector: str)"Element \| None" | Return the nearest ancestor (inclusive) matching the CSS selector. | | get_elements_by_tag_name(qualified_name: str)HTMLCollection | Return all descendant elements whose tag name matches qualified_name. | | get_elements_by_class_name(class_names: str)HTMLCollection | Return all descendant elements that carry all of the given class tokens. | | filter_fn(el: "Element")bool | Calls filter_fn(el) on this HTMLFormElement instance. | | remove() | Remove this element from its parent node. | | before() | Insert nodes immediately before this element in its parent. | | after() | Insert nodes immediately after this element in its parent. | | replace_with() | Replace this element with nodes in its parent. | | prepend() | Insert nodes before the first child of this element. | | append() | Append nodes as the last children of this element. | | replace_children() | Remove all children, then append nodes as new children. | | get_bounding_client_rect()"DOMRect" | Return the bounding client rectangle (all-zero stub). | | get_client_rects()"DOMRectList" | Return the client rectangle list (empty in server-side context). | | get_animations()list[object] | Return active animations for this element (headless stub: always []). | | attach_shadow(init: "dict \| None") | Raise NotSupportedError — shadow trees are not supported in headless mode. | | get_root_node(composed: bool)"Node" | Return the root of the node’s tree. | | has_child_nodes()bool | Return whether this node has at least one direct child node. | | lookup_namespace_uri(prefix: str \| None)str \| None | Return the effective namespace URI for prefix in this node context. | | lookup_prefix(namespace_uri: str \| None)str \| None | Return the effective prefix for namespace_uri in this node context. | | is_default_namespace(namespace_uri: str \| None)bool | Return whether namespace_uri equals this node context default namespace. | | is_supported(feature: str, version: str \| None)bool | Return legacy feature-probe compatibility status. | | get_feature(feature: str, version: str \| None)object \| None | Return the legacy feature object for a probe, or None. | | set_user_data(key: str, data: object \| None, handler: object \| None)object \| None | Store or clear node-local user data and return the previous value. | | get_user_data(key: str)object \| None | Return node-local user data for key or None when absent. | | append_child(node: Node)Node | Append node as the last child of this node. | | insert_before(node: Node, reference: Node \| None)Node | Insert node before reference in the child list. | | remove_child(node: Node)Node | Remove node from the child list and return it. | | replace_child(new_child: Node, old_child: Node)Node | Replace old_child with new_child. | | clone_node(deep: bool)Node | Return a copy of this node. | | normalize() | Put this node and its entire subtree into normalized form. | | contains(other: Node \| None)bool | Return True if other is an inclusive descendant of this node. | | compare_document_position(other: "Node")int | Return a bitmask describing the position of other relative to this node. | | is_equal_node(other: Node \| None)bool | Return True if other has the same structure as this node. | | is_same_node(other_node: Node \| None)bool | Return True when other_node is this node instance. | | add_event_listener(type: str, listener: Callable, capture: bool, once: bool) | Register listener for events of type. | | remove_event_listener(type: str, listener: Callable, capture: bool) | Deregister a previously-registered listener. | | dispatch_event(event: "Event")bool | Dispatch event through the ancestor tree. |

See Also