HTML::O...t::Input(3)
๐ NAME
Okay so bestie, welcome to HTML::Object::DOM::Element::Input โ the HTML Object DOM Input Class. (Your pager probably files it under HTML::O...t::Input(3) because terminals are dramatic about long names, but that's literally the same thing ๐ซถ)
โจ SYNOPSIS โจ
use HTML::Object::DOM::Element::Input;
my $input = HTML::Object::DOM::Element::Input->new ||
die( HTML::Object::DOM::Element::Input->error, "\n" );
๐ VERSION ๐
v0.2.2
๐ธ DESCRIPTION ๐ธ
This interface is the whole vibe for <input> elements โ it hands you the special properties and methods you need to mess with their options, their layout, and how they present themselves. No cap, it's giving main character energy for form controls. โจ
๐ฆ INHERITANCE ๐ฆ
Look at this lineage, she's iconic ๐
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +-----------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Input |
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +-----------------------------------+
๐ PROPERTIES ๐
She inherits properties from her parent HTML::Object::DOM::Element plus all the properties exported by HTML::Object::DOM::Element::Shared. Family perks, we love to see it ๐
๐ accept
This one returns or sets the element's accept HTML attribute โ that's the comma-separated list of file types the server will accept when type is file.
Mozilla docs for the curious: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
๐ accessKey
Returns a string holding a single character โ press it and input focus jumps to the control. Keyboard magic โจ
Example:
<button accesskey="s">Some button</button>
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKey and the accessKey attribute docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey
๐ allowdirs
Sets or gets a boolean. Heads up: this is part of the non-standard Directory Upload API. It indicates whether or not to allow both directories and files to be selected in the file list. It's implemented only in Firefox and it's hidden behind a preference. So likeโฆ lowkey experimental, don't build your whole life on it ๐
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#instance_properties_that_apply_only_to_elements_of_type_file
๐ alt
Returns or sets the element's alt attribute โ the alternative text that shows up when type is image (aka when the image is a no-show ๐ญ).
๐ autocapitalize
Defines the capitalization behavior for user input. The valid values are none, off, characters, words, or sentences.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#instance_properties
๐ autocomplete
Returns or sets the element's autocomplete attribute โ that's the "can the browser fill this in for you" flag. It gets ignored if type is "hidden", "checkbox", "radio", "file", or any button type ("button", "submit", "reset", "image"). Possible values:
onโ the browser can autocomplete the value using a previously stored value.offโ the user must explicitly enter a value.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autocomplete
๐ autofocus
Returns or sets the element's autofocus attribute โ it says this form control should have input focus when the page loads, unless the user overrides it (like by typing in a different control). Real talk: only one form element in a document can carry the autofocus attribute. And it cannot be applied if type is hidden โ nope, you can't auto-focus a hidden control, nice try ๐
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autofocus
๐ checked
Returns a boolean representing the current state of the element when type is checkbox or radio.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checked
๐ defaultChecked
Returns or sets a boolean representing the default state of a radio button or checkbox โ as originally specified in the HTML that created this object.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/defaultChecked
๐ defaultValue
Returns or sets the default value as originally specified in the HTML that created this object.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/defaultValue
๐ dirName
Returns or sets a string representing the directionality of the element.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/dirName
๐ disabled
Returns or sets a boolean representing the element's disabled attribute โ meaning the control is not available for interaction, and the input values will not be submitted with the form. See also readonly.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/disabled
๐ files
Returns or accepts a FileList object containing a list of File objects representing the files selected for upload. But bestie, this is a perl framework, so you'd have to set the object values yourself ๐ซ
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
๐ form
Read-only.
An HTML::Object::DOM::Element::Form object: this returns a reference to the parent <form> element.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/form
๐ formAction
Returns or sets the element's formaction attribute, which contains the "URI" of a program that processes information submitted by the element. This overrides the action attribute of the parent form.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/formAction
๐ formEnctype
Returns or sets the element's formenctype attribute, which contains the type of content used to submit the form to the server. This overrides the enctype attribute of the parent form.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/formEnctype
๐ formMethod
Returns or sets the element's formmethod attribute, which contains the HTTP method the browser uses to submit the form. This overrides the method attribute of the parent form.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/formMethod
๐ formNoValidate
Returns or sets a boolean representing the element's "formnovalidate" HTML attribute โ it says the form is not to be validated when it's submitted. This overrides the "novalidate" attribute of the parent form.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/formNoValidate
๐ formTarget
Returns or sets the element's formtarget attribute, which contains a name or keyword indicating where to display the response received after submitting the form. This overrides the target attribute of the parent form.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/formTarget
๐ height
Returns or sets the element's height attribute, which defines the height of the image displayed for the button โ but only if the value of type is image. iykyk ๐ผ๏ธ
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/height
๐ indeterminate
Returns a boolean representing whether the checkbox or radio button is in an indeterminate state. For checkboxes the effect is that the checkbox looks obscured/greyed in some way to signal "not checked but not unchecked" โ very much a vibe check in limbo ๐. It does not affect the value of the checked attribute, and clicking the checkbox will set the value to false.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/indeterminate
๐ inputmode
Provides a hint to browsers about the type of virtual keyboard configuration to use when editing this element or its contents.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/inputmode
๐ labels
Read-only.
Returns an array object of "label" elements that are labels for this element. Obsessed with a good label era ๐
Example:
<label id="label1" for="test">Label 1</label>
<input id="test" />
<label id="label2" for="test">Label 2</label>
window->addEventListener( DOMContentLoaded => sub
{
my $input = $doc->getElementById( 'test' );
for( my $i = 0; $i < $input->labels->length; $i++ )
{
say( $input->labels->[$i]->textContent ); # "Label 1" and "Label 2"
}
});
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
๐ list
Read-only.
Returns the element pointed to by the list attribute. Heads up: the property may be "undef" if no HTML element is found in the same tree ๐ซ
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/list
๐ max
Returns or sets a string representing 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.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/max
๐ maxLength
Returns or sets a long representing the element's "maxlength" attribute, containing the maximum number of characters (in Unicode code points) the value can have. โ ๏ธ If you set this to a negative number, an exception will be thrown.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/maxLength
๐ min
Returns or sets a string representing 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.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/min
๐ minLength
Returns or sets a long representing the element's "minlength" attribute, containing the minimum number of characters (in Unicode code points) the value can have. โ ๏ธ If you set this to a negative number, an exception will be thrown.
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/minLength
multiple
Gets/sets a boolean, and it's literally the element's multiple attribute โ the one that says "yes bestie you can pick MORE than one value" (multiple files, for example ๐๏ธ).
Example, because iykyk:
# $fileInput is a <input type=$file multiple>
my $fileInput = $doc->getElementById('myfileinput');
# If true
if( $fileInput->multiple )
{
for( my $i = 0; $i < $fileInput->files->length; $i++ )
{
# Loop $fileInput->files
}
}
# Only one $file available
else
{
my $file = $fileInput->files->item(0);
}
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/multiple
name
Gets/sets a string, the element's name attribute โ the lil name tag that identifies the element when the form gets submitted ๐ฎ.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/name
pattern
Gets/sets a string, the element's pattern attribute โ a regular expression that the control's value gets checked against ๐. Pro tip straight from the source: use the title attribute to describe the pattern so the user isn't just confused. This attribute only applies when the type attribute is "text", "search", "tel", "url" or "email"; otherwise it's ignored, no cap.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/pattern
placeholder
Gets/sets a string, the element's placeholder attribute โ the little hint text telling the user what they can type in there โ๏ธ. Important: the placeholder text must not contain carriage returns or line-feeds, okay? This attribute applies when type is "text", "search", "tel", "url" or "email"; otherwise it is ignored.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/placeholder
readOnly
Gets/sets a boolean, the element's readonly HTML attribute โ meaning the user literally cannot modify the value of the control ๐. This one is ignored if type is hidden, range, color, checkbox, radio, file, or any button type.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/readOnly
required
Gets/sets a boolean, the element's required attribute โ the "you SHALL NOT submit an empty form" flag ๐
โโ๏ธ โ the user must fill in a value before submitting.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/required
selectionDirection
Gets/sets a string โ the direction in which the selection happened. Possible values, bestie:
forwardโ if selection was performed in the start-to-end direction of the current localebackwardโ for the opposite directionnoneโ if the direction is unknown
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/selectionDirection
selectionEnd
Gets/sets an unsigned long โ the end index of the selected text. When there's no selection at all, it returns the offset of the character immediately following the current text input cursor position ๐ฑ๏ธ.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/selectionEnd
selectionStart
Gets/sets an unsigned long โ 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 โจ.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/selectionStart
size
Gets/sets an unsigned long, the element's size attribute โ the visual size of the control. Heads up: this value is in pixels, unless type is text or password, in which case it's an integer number of characters. Applies only when type is set to "text", "search", "tel", "url", "email", or "password"; otherwise ignored ๐
.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/size
src
Gets/sets a string, the element's src attribute โ it specifies a URI for the location of an image to display on the graphical submit button, if type is image; otherwise it's ignored ๐ผ๏ธ.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/src
step
Gets/sets a string, the element's step attribute โ it works together with min and max to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If it's not set to any, the control accepts only values at multiples of the step value greater than the minimum ๐.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/step, and the documentation on step attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step
type
Gets/sets a string, the element's type attribute โ indicating the type of control to display. See type attribute of <input> for possible values ๐.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/type
validationMessage
Read-only ๐จ.
Gets/sets a string โ a localised message describing the validation constraints that the control does not satisfy (if any). It's the empty string if the control isn't a candidate for constraint validation (willvalidate is false), or if it satisfies its constraints. This value can also be set by the setCustomValidity method.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/validationMessage
validity
Read-only ๐จ.
Gets/sets the element's current validity state object.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/validity
value
Gets/sets a string โ the current value of the control ๐.
Note: if the user enters a value different from the value expected, this may return an empty string.
This interface does not enforce a proper value, so it's 100% on you to use the right one. For example, using a value of "2021-W55" for an input of type "week" is normally illegal, since the week number value should be a number between 1 and 53 ๐.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value
valueAsDate
Gets/sets a date โ the value of the element interpreted as a date, or undef if conversion is not possible ๐
.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/valueAsDate
valueAsNumber
Returns a double โ the value of the element interpreted as one of the following, in this exact order:
- A time value
- A number
NaN(undef) if conversion is impossible
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/valueAsNumber
webkitEntries
This always returns undef under perl ๐.
Under JavaScript, it returns an Array of FileSystemEntry objects that describes the currently selected files or directories.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries
webkitdirectory
Gets/sets a boolean, the webkitdirectory HTML attribute โ if true, the file system picker interface only accepts directories instead of files ๐โจ.
Example:
<input type="file" id="filepicker" name="fileList" webkitdirectory multiple />
<ul id="listing"></ul>
$doc->getElementById( 'filepicker' )->addEventListener( change => sub
{
my $output = $doc->getElementById( 'listing' );
my $files = event->target->files;
for( my $i=0; $i < $files->length; $i++ )
{
my $item = $doc->createElement( 'li' );
$item->innerHTML = $files->[$i]->webkitRelativePath;
$output->appendChild( $item );
};
}, { capture => 0 });
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
width
Gets/sets a string, the element's width attribute โ it defines the width of the image displayed for the button, if type is image ๐.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/width
willValidate
Read-only ๐จ.
Gets/sets a boolean โ whether the element is a candidate for constraint validation. It's false if any conditions bar it from constraint validation, including: its type is hidden, reset, or button; it has a datalist ancestor; or its disabled property is true ๐ซ.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/willValidate
โจ METHODS โจ
Okay so bestie, this is where the actual โจdoing stuffโจ happens. First up, the boring-but-important bit:
- Inherits methods from its parent
HTML::Object::DOM::Element๐ซถ
๐ mozGetFileNameArray
So this one is a whole lot of nothing, ngl. Since this is a perl environment, this has no effect and always returns undef. That's it. That's the method. ๐
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/mozGetFileNameArray
๐ mozSetFileArray
Yeahโฆ same vibe. Since this is a perl environment, this has no effect and always returns undef. Iconic in its uselessness, honestly. ๐ฆ
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/mozSetFileArray
๐ setCustomValidity
Thee method for when you need to be like "bestie, this input is NOT valid" and you want to say it in your own words ๐
It sets a custom message to display if the input element's value is not valid.
See Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
๐ stepDown
Decrements the value by (step * n), where n defaults to 1 if not specified. So it's like going backwards down the number line, one lil step at a time ๐
It returns an HTML::Object::InvalidStateError error in these situations:
- if the method is not applicable to for the current type value,
- if the value cannot be converted to a number or recognised as a
DateTimeobject when applicable, - if the resulting value is above the
maxor below theminset by their respective HTML attribute.
And if the element has no step value, step defaults to 1.
Here's the tea on the supported types and their equivalent values ๐
dateโ unit is1(day).
<input type="date" min="2019-12-25" step="1" />
This defaults to 1970-01-01 if not value is set yet, but if a max value is set and stepDown is called, the initial value will be that of max and if min value is set and stepUp is called, the initial value will be that of min
monthโ unit is1(month).
<input type="month" min="2019-12" step="12" />
This defaults to 1970-01 if not value is set yet, but if a max value is set and stepDown is called, the initial value will be that of max and if min value is set and stepUp is called, the initial value will be that of min
weekโ unit is1(week).
<input type="week" min="2019-W23" step="2" />
This defaults to 1970-W1 if not value is set yet, but if a max value is set and stepDown is called, the initial value will be that of max and if min value is set and stepUp is called, the initial value will be that of min
timeโ unit is60(seconds).
<input type="time" min="09:00" step="900" />
This defaults to 00:00 if not value is set yet, but if a max value is set and stepDown is called, the initial value will be that of max and if min value is set and stepUp is called, the initial value will be that of min
datetime-localโ unit is1(second).
<input type="datetime-local" min="2019-12-25T19:30:01" step="7" />
This defaults to 1970-01-01T00:00:00 if not value is set yet, but if a max value is set and stepDown is called, the initial value will be that of max and if min value is set and stepUp is called, the initial value will be that of min
This also supports the following format 2019-12-25T19:30, i.e. without seconds, and 2019-12-25T19, i.e. without minutes or seconds
numberโ unit is1.
<input type="number" min="0" step="0.1" max="10" />
rangeโ unit is1.
<input type="range" min="0" step="2" max="10" />
Now here's the part that's genuinely so interesting, ok, listen up ๐
Interestingly enough, if you have the following HTML:
<input type="time" min="17:00" step="900" />
and call stepUp, it will set the value the first time to 17:00, then the second time to 17:15.
However, the other way around is not true, i.e.
<input type="time" max="17:00" step="900" />
Then a call to stepDown will not yield the value 17:00, but instead 23:45, the second time to 17:00 and third time to 16:45. A bug report No 1749427 was filed to Mozilla https://bugzilla.mozilla.org/show_bug.cgi?id=1749427 and to Chromium https://bugs.chromium.org/p/chromium/issues/detail?id=1286160 on 2022-01-11 and is preemptively corrected here in this interface. ๐โจ (We fixed it first, no cap.)
Example:
<!-- decrements by intervals of 900 seconds (15 minute) -->
<input type="time" max="17:00" step="900" />
<!-- decrements by intervals of 7 days (one week) -->
<input type="date" max="2019-12-25" step="7" />
<!-- decrements by intervals of 12 months (one year) -->
<input type="month" max="2019-12" step="12" />
$element->stepDown( [ $stepDecrement ] );
Another example:
<p>
<label>Enter a number between 0 and 400 that is divisible by 5:
<input type="number" step="5" id="theNumber" min="0" max="400" />
</label>
</p>
<p>
<label>Enter how many values of step you would like to decrement by or leave it blank:
<input type="number" step="1" id="decrementer" min="-2" max="15" />
</label>
</p>
<input type="button" value="Decrement" id="theButton" />
# make the $button call the function
my $button = $doc->getElementById('theButton');
$button->addEventListener( click => sub
{
&stepondown();
});
sub stepondown
{
my $input = $doc->getElementById('theNumber');
my $val = $doc->getElementById('decrementer')->value;
# decrement with a parameter
if( $val )
{
$input->stepDown( $val );
}
# or without a parameter. Try it with 0, 5, -2, etc.
else
{
$input->stepDown();
}
}
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepDown, and Mozilla documentation on step https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step
๐ stepUp
The opposite twin of stepDown, and honestly she's the main character ๐
Increments the value by (step * n), where n defaults to 1 if not specified. Returns an HTML::Object::InvalidStateError error in these cases:
- if the method is not applicable to for the current type value.,
- if the element has no step value,
- if the value cannot be converted to a number,
- if the resulting value is above the max or below the min.
Supported types and equivalent values are the same as for stepDown ๐ (scroll up bestie, they're all right there.)
Example:
<p>
<label>Enter a number between 0 and 400 that is divisible by 5:
<input type="number" step="5" id="theNumber" min="0" max="400" />
</label>
</p>
<p>
<label>Enter how many values of step you would like to increment by or leave it blank:
<input type="number" step="1" id="incrementer" min="0" max="25" />
</label>
</p>
<input type="button" value="Increment" id="theButton" />
# make the $button call the function
my $button = $doc->getElementById('theButton')
$button->addEventListener( click => sub
{
&steponup();
})
sub steponup
{
my $input = $doc->getElementById('theNumber');
my $val = $doc->getElementById('incrementer')->value;
# increment with a parameter
if( $val )
{
$input->stepUp( $val );
}
# or without a parameter. Try it with 0
else
{
$input->stepUp();
}
}
Another example:
<input max="4096" min="1" name="size" step="2" type="number" value="4096" id="foo" />
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepUp, and Mozilla documentation on step https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step
๐ EVENTS ๐
okay bestie, you can also find listeners for these events by prepending on before the event type โ it's giving convenience ๐
For example, input event listeners can be set also with the oninput method:
$e->oninput(sub{ # do something });
# or as an lvalue method
$e->oninput = sub{ # do something };
๐ธ input
Fires when the value of an input, select, or textarea element has been changed. Note that this is actually fired on the HTML::Object::DOM::Element interface and also applies to contenteditable elements, but we've listed it here because it is most commonly used with form input elements. Also available via the oninput event handler property.
Example:
<input placeholder="Enter some text" name="name" />
<p id="values"></p>
my $input = $doc->querySelector('input');
my $log = $doc->getElementById('values');
$input->addEventListener( input => \&updateValue );
sub updateValue
{
my $e = shift( @_ );
$log->textContent = $e->target->value;
}
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event
๐ฆ invalid
Fired when an element does not satisfy its constraints during constraint validation. Also available via the oninvalid event handler property.
Example:
<form action="#">
<ul>
<li><label>Enter an integer between 1 and 10: <input type="number" min="1" max="10" required></label></li>
<li><input type="submit" value="submit"></li>
</ul>
</form>
<p id="log"></p>
my $input = $doc->querySelector('input');
my $log = $doc->getElementById('log');
$input->addEventListener( invalid => \&logValue );
sub logValue
{
my $e = shift( @_ )l
$log->textContent = $e->target->value;
}
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/invalid_event
๐ search
Fired when a search is initiated on an <input> of type="search". Also available via the onsearch event handler property.
Example:
# addEventListener version
my $input = $doc->querySelector('input[type="search"]');
$input->addEventListener( search => sub
{
say( "The term searched for was " . $input->value );
})
# onsearch version
my $input = $doc->querySelector( 'input[type="search"]' );
$input->onsearch = sub
{
say( "The term searched for was " + $input->value );
})
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/search_event
selectionchange
Fires when the text selection in a input element has been changed.
Example:
<div>Enter and select text here:<br />
<input id="mytext" rows="2" cols="20" />
/div>
<div>selectionStart: <span id="start"></span></div>
<div>selectionEnd: <span id="end"></span></div>
<div>selectionDirection: <span id="direction"></span></div>
my $myinput = $doc->getElementById( 'mytext' );
$myinput->addEventListener( selectionchange => sub
{
$doc->getElementById( 'start' )->textContent = $myinput->selectionStart;
$doc->getElementById( 'end' )->textContent = $myinput->selectionEnd;
$doc->getElementById( 'direction' )->textContent = $myinput->selectionDirection;
});
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/selectionchange_event
๐ DEPRECATED PROPERTIES ๐
bestie, these are lowkey deprecated โ don't make them your main character unless you truly have to ๐ซถ
๐ธ align
Provided with a string, and this sets or gets the HTML attribute that represents the alignment of the element. It is better to use CSS instead.
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/align
๐บ๏ธ useMap
A string reflecting the usemap HTML attribute, containing the page-local URL of the <map"> element describing the image map to use. The page-local URL is a pound (hash) symbol (#) followed by the ID of the <map"> element, such as #my-map-element. The <map"> in turn contains <area"> elements indicating the clickable areas in the image.
Example:
<map name="mainmenu-map">
<area shape="circle" coords="25, 25, 75" href="/index.html" alt="Return to home page">
<area shape="rect" coords="25, 25, 100, 150" href="/index.html" alt="Shop">
</map>
<input usemap="#mainmenu-map" />
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/useMap
๐ AUTHOR ๐
Jacques Deguest โ jack@deguest.jp
๐ฆ SEE ALSO ๐ฆ
- Mozilla documentation:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement - Mozilla documentation on input element:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
๐ 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.
okay bestie that's the whole page ๐ it's HTML::O...t::Input(3) from perl v5.42.2, dated 2026-02-15 โ go forth and make something iconic ๐ซถโจ
๐ฆ 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