HTML::O...:Shared(3)
πΈ NAME
HTML::Object::DOM::Element::Shared β aka the HTML Object DOM Form Shared Code page, from the User Contributed Perl Documentation section (HTML::O...:Shared(3), if you're squinting at the short version) π
β¨ SYNOPSIS
use HTML::Object::DOM::Element::Shared qw( :input );
π VERSION
v0.2.0
π¦ DESCRIPTION
Okay so bestie, listen π β this module is literally the shared closet. It implements all the properties and methods that get passed around between several form elements, so every form element doesn't have to re-implement them from scratch. Iconic, honestly.
π PROPERTIES
π accept
Set or return the element's accept attribute β it's the comma-separated list of file types the server will accept when type is file. Fr fr, it's just the "what snacks are allowed" list.
β accessKey
Sets or gets the element's attribute representing a string containing a single character that switches input focus to the control when you press it. One character. Not two. Don't get greedy π
π allowdirs
Set or get a boolean value. This does not do anything otherwise since this is not an attribute β so like, it's giving decorative, lowkey.
This is part of the Mozilla non-standard Directory Upload API. It indicates whether or not to allow directories and files both to be selected in the file list.
π§ alt
Sets or returns the element's alt attribute, containing the alternative text to use when type is image. The understudy text, iykyk.
π«Ά autocapitalize
Defines the capitalization behavior for user input. Valid values are "none", "off", "characters", "words", or "sentences". Pick your fighter.
π autocomplete
Set or returns a string that represents the element's autocomplete attribute, indicating whether the value of the control can be automatically completed by the browser.
Ignored if the value of thetypeattribute is"hidden","checkbox","radio","file", or a"button"type ("button","submit","reset","image"). So don't even try it with those, it's not going to happen π
Possible values are:
onβ the browser can autocomplete the value using previously stored value β¨offβ the user must explicity enter a value
π₯ autofocus
Set or returns a boolean value that represents the element's autofocus attribute, which specifies that a form control should have input focus when the page loads β unless the user overrides it, for example by typing in a different control. Main character energy, but only one of them gets it.
Only one form element in a document can have the autofocus attribute. And it cannot be applied if the type attribute is set to hidden β that is, you cannot automatically set focus to a hidden control. No sneaky focus for the invisible ones π
π©· checked
Set or returns a boolean value the current state of the element when type is checkbox or radio.
π¦ crossOrigin
A string of a keyword specifying the CORS mode to use when fetching the image resource. If you do not specify crossOrigin, the underlying element is fetched without CORS (the fetch no-cors mode).
Permitted values are:
"anonymous"β Requests by the underlying element have their mode set tocorsand their credentials mode set tosame-origin. This means that CORS is enabled and credentials are sent if the underlying element is fetched from the same origin from which the document was loaded."use-credentials"β Requests by theHTML::Object::DOM::Elementwill use thecorsmode and theincludecredentials mode; all underlying element requests by the element will use CORS, regardless of what domain the fetch is from.
If crossOrigin is an empty string (""), the anonymous mode is selected. Fun little default, love that for us π
See Mozilla documentation for more information: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
πΈ defaultChecked
Set or returns a boolean value that sets the default state of a radio button or checkbox as originally specified in HTML that created this object. It's the factory setting, the og vibe β¨
π§Έ dirName
Sets or gets the directionality of the element.
π disabled
Set or returns a boolean value that represents the element's disabled attribute, indicating that the control is not available for interaction. The input values will not be submitted with the form. See also "readonly". It's benched. Not in the group chat anymore.
π files
This returns a HTML::Object::DOM::FileList object.
Under JavaScript, this returns or accepts a "FileList" object, which contains a list of "File" objects representing the files selected for upload π
π form
The "form" HTML element represents a document section containing interactive controls for submitting information.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
β formAction
Is a string reflecting the URI of a resource that processes information submitted by the button. If specified, this property overrides the action attribute of the "<form"> element that owns this element.
This is used by HTML::Object::DOM::Element::Input
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formAction
π formEnctype
Is a string reflecting the type of content that is used to submit the form to the server. If specified, this property overrides the enctype attribute of the "<form"> element that owns this element.
This is used by HTML::Object::DOM::Element::Input
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formEnctype
π₯ formMethod
Is a string reflecting the HTTP method that the browser uses to submit the form. If specified, this property overrides the method attribute of the <form> element that owns this element.
This is used by HTML::Object::DOM::Element::Input
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formMethod
π formNoValidate
Is a boolean value indicating that the form is not to be validated when it is submitted. If specified, this property overrides the novalidate attribute of the <form> element that owns this element.
This is used by HTML::Object::DOM::Element::Input
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formNoValidate
π formTarget
Is a string reflecting a name or keyword indicating where to display the response that is received after submitting the form. If specified, this property overrides the target attribute of the <form> element that owns this element.
This is used by HTML::Object::DOM::Element::Input
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/formTarget
π§ hash
The hash property of the Location interface returns a string containing a '#' followed by the fragment identifier of the URL β the ID on the page that the URL is trying to target. It's the "scroll to this bit" of the internet, periodt.
The fragment is not percent-decoded. If the URL does not have a fragment identifier, this property contains an empty string, "".
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/hash
π«Ά height
Sets or returns the element's height attribute, which defines the height of the image displayed for the button, if the value of type is image.
π host
The host property of the Location interface is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', and the port of the URL.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/host
πΈ hostname
The hostname property of the Location interface is a string containing the domain of the URL. Just the domain. No plus-one, no port.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/hostname
β href
The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated. Yes bestie, it's both a getter and a setter β dual threat π
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/href
π indeterminate
Set or returns a boolean value that describes whether the checkbox or radio button is in indeterminate state.
For checkboxes, the effect is that the appearance of the checkbox is obscured/greyed in some way as to indicate its state is indeterminate (not checked but not unchecked). It does not affect the value of the checked attribute, and clicking the checkbox will set the value to false. The "I don't know her" state, honestly π
π¦ inputmode
Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. Very "let them know which keyboard to bring" of it.
π§Έ labels
Returns a list of "<label"> elements that are labels for this element, as an array object.
π list
Sets or returns the element pointed by the "list" attribute, which returns an ID. The property may be undef if no HTML element found in the same tree. Ghosted π«₯
π₯ max
Set or returns a string that represents the element's "max" attribute, containing the maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
π maxLength
Set or returns an integer that represents the element's "maxlength" attribute, containing the maximum number of characters (in Unicode code points) that the value can have.
Side note: if you set this to a negative number, an exception will be thrown. So maybe don't π
π min
Set or returns a string that represents the element's "min" attribute, containing the minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
π§ minLength
Set or returns an integer that represents the element's "minlength" attribute, containing the minimum number of characters (in Unicode code points) that the value can have.
Same warning, bestie: if you set this to a negative number, an exception will be thrown π
π«Ά multiple
Sets or returns a boolean that represents the element's multiple attribute, indicating whether more than one value is possible (e.g., multiple files). Sharing is caring.
π name
Set or returns the element's name attribute, containing a name that identifies the element when submitting the form.
πΈ password
The password property of the Location interface is a string containing the password specified before the domain name. Don't go printing this one in public, mwah π
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/password
β pathname
The pathname property of the Location interface is a USVString containing the path of the URL for the location, which will be the empty string if there is no path.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname
π pattern
Set or returns a string that represents the element's "pattern" attribute, containing a regular expression that the control's value is checked against. Use the "title" attribute to describe the pattern to help the user β because nobody can read a regex, let's be real π
This attribute applies when the value of the type attribute is "text", "search", "tel", "url" or "email"; otherwise it is ignored.
π¦ placeholder
Set or returns a string that represents the element's "placeholder" attribute, containing a hint to the user of what can be entered in the control.
The "placeholder" text must not contain carriage returns or line-feeds. This attribute applies when the value of the type attribute is "text", "search", "tel", "url" or "email"; otherwise it is ignored.
readOnlyβ sets or returns a boolean for the element'sreadonlyattribute, i.e. "bestie you literally cannot touch this value". Heads up tho: it's completely ignored if thetypeattribute ishidden,range,color,checkbox,radio,file, or any of the button types. Like, the universe just says no. πrelβ therelattribute, which defines the relationship between a linked resource and the current document. It's giving "who are you to me" energy.
Also see the Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel π¦
requiredβ sets or returns a boolean for the element'srequiredattribute, indicating the user must fill in a value before submitting a form. No skipping, no shortcuts, no vibes-only submissions. πsearchβ thesearchproperty of the Location interface: a search string, also called a query string, aka aUSVStringcontaining a'?'followed by the parameters of the URL. That little?whatever=thingera. β¨
Also see the Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/Location/search
selectionDirectionβ sets or returns a string representing the direction in which selection occurred. Possible values:forwardβ if selection was performed in the start-to-end direction of the current localebackwardβ for the opposite directionnoneβ if the direction is unknown
selectionEndβ sets or returns an integer representing the end index of the selected text. When there's no selection, this returns the offset of the character immediately following the current text input cursor position. Lowkey the "right where you left it" property. πselectionStartβ sets or returns an integer representing the beginning index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the<input>element.sizeβ sets or returns an integer for the element'ssizeattribute, containing the visual size of the control. This value is in pixels unless the value oftypeistextorpassword, in which case it's an integer number of characters. Applies only whentypeis set totext,search,tel,url,email, orpassword; otherwise it is ignored. Picky little icon. πstepβ sets or returns the element'sstepattribute, which works withminandmaxto limit the increments at which a numeric or date-time value can be set. It can be the stringanyor a positive floating point number. If this is not set toany, the control accepts only values at multiples of thestepvalue greater than the minimum. Math girlies rise. π₯srcβ sets or returns the element'ssrcattribute, which specifies a URI for the location of an image to display on the graphical submit button, if the value oftypeisimage; otherwise it is ignored. Main character image button only. πtypeβ sets or returns the element'stypeattribute, indicating the type of control to display. Seetypeattribute of"<input">for possible values.valueβ sets or returns the current value of the control. The whole point, honestly. βvalueAsDateβ sets or returns the value of the element, interpreted as aDateTimeobject, orundefif conversion is not possible.valueAsNumberβ returns the value of the element, interpreted as one of the following, in order:- A time value
- A number
undefif conversion is impossible
validityβ Read-only.
ValidityState object: returns the element's current validity state. It's giving "vibe check but for forms". π§
validationMessageβ Read-only.
Sets or returns a localised message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willvalidate is false), or it satisfies its constraints. This value can be set by the setCustomValidity method. Custom apology letter, basically. π
webkitdirectoryβ a boolean value: returns thewebkitdirectoryattribute; if true, the file system picker interface only accepts directories instead of files. Folders only, no loose files, periodt. π
Also see the Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
webkitEntriesβ this does nothing under perl, and returnsundef. Rip. π«Ά
Also see the Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries
widthβ sets or returns the element'swidthattribute, which defines the width of the image displayed for the button, if the value oftypeisimage.willValidateβ Read-only.
Sets or returns a boolean value that describes whether the element is a candidate for constraint validation. It is false if any conditions bar it from constraint validation, including: its type is hidden, reset, or button; it has a <datalist> ancestor; its disabled property is true. Not everyone gets to be a candidate, and that's okay. β
π METHODS π
checkValidity
In perl, this always returns true, or whatever value you would have set. Slay, effortless. β¨
In a JavaScript environment, this returns true if the element's child controls are subject to constraint validation and satisfy those constraints; returns false if some controls do not satisfy their constraints. Fires an event named invalid at any control that does not satisfy its constraints; such controls are considered invalid if the event is not canceled. It is up to the programmer to decide how to respond to false. Yes bestie, that's you β you decide. π
Also see the Mozilla documentation on form at https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/checkValidity, and the Mozilla doc on input at https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
reportValidity
In perl, this always returns true, or whatever value you would have set. π
In a JavaScript environment, this returns true if the element's child controls satisfy their validation constraints. When false is returned, cancelable invalid events are fired for each invalid child and validation problems are reported to the user. It's giving "snitching, but helpfully". π
Example:
$doc->forms->myform->addEventListener( submit => sub
{
$doc->forms->myform->reportValidity();
}, { capture => 0 });
Also see the Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity, and the Mozilla doc on input at https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity
πΈ AUTHOR πΈ
Jacques Deguest <jack@deguest.jp> β the icon who wrote all this. Respect. π«Ά
π¦ SEE ALSO π¦
The whole found family, no cap:
HTML::Object::DOM::ElementHTML::Object::DOM::Element::AnchorHTML::Object::DOM::Element::AreaHTML::Object::DOM::Element::AudioHTML::Object::DOM::Element::BaseHTML::Object::DOM::Element::BodyHTML::Object::DOM::Element::BRHTML::Object::DOM::Element::ButtonHTML::Object::DOM::Element::CanvasHTML::Object::DOM::Element::DataListHTML::Object::DOM::Element::DataHTML::Object::DOM::Element::DetailsHTML::Object::DOM::Element::DialogHTML::Object::DOM::Element::DirectoryHTML::Object::DOM::Element::DivHTML::Object::DOM::Element::DListHTML::Object::DOM::Element::EmbedHTML::Object::DOM::Element::FieldSetHTML::Object::DOM::Element::FormHTML::Object::DOM::Element::HeadingHTML::Object::DOM::Element::HeadHTML::Object::DOM::Element::HRHTML::Object::DOM::Element::HTMLHTML::Object::DOM::Element::IFrameHTML::Object::DOM::Element::ImageHTML::Object::DOM::Element::InputHTML::Object::DOM::Element::LabelHTML::Object::DOM::Element::LegendHTML::Object::DOM::Element::LinkHTML::Object::DOM::Element::LIHTML::Object::DOM::Element::MapHTML::Object::DOM::Element::MarqueeHTML::Object::DOM::Element::MediaHTML::Object::DOM::Element::MenuHTML::Object::DOM::Element::MetaHTML::Object::DOM::Element::MeterHTML::Object::DOM::Element::ModHTML::Object::DOM::Element::ObjectHTML::Object::DOM::Element::OListHTML::Object::DOM::Element::OptGroupHTML::Object::DOM::Element::OptionHTML::Object::DOM::Element::OutputHTML::Object::DOM::Element::ParagraphHTML::Object::DOM::Element::ParamHTML::Object::DOM::Element::PictureHTML::Object::DOM::Element::PreHTML::Object::DOM::Element::ProgressHTML::Object::DOM::Element::QuoteHTML::Object::DOM::Element::ScriptHTML::Object::DOM::Element::SelectHTML::Object::DOM::Element::SlotHTML::Object::DOM::Element::SourceHTML::Object::DOM::Element::SpanHTML::Object::DOM::Element::StyleHTML::Object::DOM::Element::TableCaptionHTML::Object::DOM::Element::TableCellHTML::Object::DOM::Element::TableColHTML::Object::DOM::Element::TableHTML::Object::DOM::Element::TableRowHTML::Object::DOM::Element::TableSectionHTML::Object::DOM::Element::TemplateHTML::Object::DOM::Element::TextAreaHTML::Object::DOM::Element::TimeHTML::Object::DOM::Element::TitleHTML::Object::DOM::Element::TrackHTML::Object::DOM::Element::UListHTML::Object::DOM::Element::UnknownHTML::Object::DOM::Element::Video
π COPYRIGHT & LICENSE π
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Free as in bestie, fr fr. π
Okay that's the whole page, you made it to the end! π This little masterpiece is perl v5.42.2, dated 2026-02-15 β go forth and validate your forms, you gorgeous creature. π
β¨
π¦ where this page comes from
- alpine 3.24: perl-html-object-doc 0.6.0-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms