The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTML::Object::DOM::Element::Shared - HTML Object DOM Form Shared Code

SYNOPSIS

    use HTML::Object::DOM::Element::Shared qw( :input );

VERSION

    v0.2.0

DESCRIPTION

This module implements properties and methods shared among several form elements

PROPERTIES

accept

Set or return the element's accept attribute, containing comma-separated list of file types accepted by the server when type is file.

accessKey

Sets or gets the element's attribute representing a string containing a single character that switches input focus to the control when pressed.

allowdirs

Set or get a boolean value. This does not do anything otherwise since this is not an attribute.

This is part of 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 alternative text to use when type is image.

autocapitalize

Defines the capitalization behavior for user input. Valid values are none, off, characters, words, or sentences.

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 the type attribute is hidden, checkbox, radio, file, or a button type (button, submit, reset, image). 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. Only one form element in a document can have the autofocus attribute. It cannot be applied if the type attribute is set to hidden (that is, you cannot automatically set focus to a hidden control).

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 to cors and their credentials mode set to same-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 the HTML::Object::DOM::Element will use the cors mode and the include credentials 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.

See Mozilla documentation for more information

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.

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"

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

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

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

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

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

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

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.

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

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

hostname

The hostname property of the Location interface is a string containing the domain of the URL.

See also Mozilla documentation

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.

See also Mozilla documentation

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). Does not affect the value of the checked attribute, and clicking the checkbox will set the value to false.

inputmode

Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents.

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.

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. (If you set this to a negative number, an exception will be thrown.)

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. (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).

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.

See also Mozilla documentation

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

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. 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

Set or returns a boolean that represents the element's readonly attribute, indicating that the user cannot modify the value of the control. This is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type.

rel

The rel attribute defines the relationship between a linked resource and the current document.

See also Mozilla documentation

required

Set or returns a boolean value that represents the element's required attribute, indicating that the user must fill in a value before submitting a form.

The search property of the Location interface is a search string, also called a query string; that is, a USVString containing a '?' followed by the parameters of the URL.

See also Mozilla documentation

selectionDirection

Set or returns a string that represents the direction in which selection occurred. Possible values are:

forward

if selection was performed in the start-to-end direction of the current locale

backward

for the opposite direction

none

if the direction is unknown

selectionEnd

Set or returns an integer that represents 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.

selectionStart

Set or returns an integer that represents 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

Set or returns an integer that represents the element's size attribute, containing visual size of the control. This value is in pixels unless the value of type is text or password, in which case, it is an integer number of characters. Applies only when type is set to text, search, tel, url, email, or password; otherwise it is ignored.

step

Set or returns the element's step attribute, which works 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 this is not set to any, the control accepts only values at multiples of the step value greater than the minimum.

src

Sets or returns the element's src attribute, which specifies a URI for the location of an image to display on the graphical submit button, if the value of type is image; otherwise it is ignored.

type

Set or returns the element's type attribute, indicating the type of control to display. See type attribute of <input> for possible values.

value

Set or returns the current value of the control.

valueAsDate

Sets or returns the value of the element, interpreted as a DateTime object, or undef if conversion is not possible.

valueAsNumber

Returns the value of the element, interpreted as one of the following, in order:

  • A time value

  • A number

  • undef if conversion is impossible

validity

Read-only.

ValidityState object: Returns the element's current validity state.

validationMessage

Read-only.

Set 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.

webkitdirectory

A boolean value: Returns the webkitdirectory attribute; if true, the file system picker interface only accepts directories instead of files.

See Mozilla documentation

webkitEntries

This does nothing under perl, and returns undef

See Mozilla documentation

width

Sets or returns the element's width attribute, which defines the width of the image displayed for the button, if the value of type is image.

willValidate

Read-only.

Set 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.

METHODS

checkValidity

In perl, this always returns true, or whatever value you would have set.

In 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.

See also Mozilla documentation on form, Mozilla doc on input

reportValidity

In perl, this always returns true, or whatever value you would have set.

In 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.

Example:

    $doc->forms->myform->addEventListener( submit => sub
    {
        $doc->forms->myform->reportValidity();
    }, { capture => 0 });

See also Mozilla documentation, Mozilla doc on input

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

HTML::Object::DOM::Element, HTML::Object::DOM::Element::Anchor HTML::Object::DOM::Element::Area HTML::Object::DOM::Element::Audio HTML::Object::DOM::Element::Base HTML::Object::DOM::Element::Body HTML::Object::DOM::Element::BR HTML::Object::DOM::Element::Button HTML::Object::DOM::Element::Canvas HTML::Object::DOM::Element::DataList HTML::Object::DOM::Element::Data HTML::Object::DOM::Element::Details HTML::Object::DOM::Element::Dialog HTML::Object::DOM::Element::Directory HTML::Object::DOM::Element::Div HTML::Object::DOM::Element::DList HTML::Object::DOM::Element::Embed HTML::Object::DOM::Element::FieldSet HTML::Object::DOM::Element::Form HTML::Object::DOM::Element::Heading HTML::Object::DOM::Element::Head HTML::Object::DOM::Element::HR HTML::Object::DOM::Element::HTML HTML::Object::DOM::Element::IFrame HTML::Object::DOM::Element::Image HTML::Object::DOM::Element::Input HTML::Object::DOM::Element::Label HTML::Object::DOM::Element::Legend HTML::Object::DOM::Element::Link HTML::Object::DOM::Element::LI HTML::Object::DOM::Element::Map HTML::Object::DOM::Element::Marquee HTML::Object::DOM::Element::Media HTML::Object::DOM::Element::Menu HTML::Object::DOM::Element::Meta HTML::Object::DOM::Element::Meter HTML::Object::DOM::Element::Mod HTML::Object::DOM::Element::Object HTML::Object::DOM::Element::OList HTML::Object::DOM::Element::OptGroup HTML::Object::DOM::Element::Option HTML::Object::DOM::Element::Output HTML::Object::DOM::Element::Paragraph HTML::Object::DOM::Element::Param HTML::Object::DOM::Element::Picture HTML::Object::DOM::Element::Pre HTML::Object::DOM::Element::Progress HTML::Object::DOM::Element::Quote HTML::Object::DOM::Element::Script HTML::Object::DOM::Element::Select HTML::Object::DOM::Element::Slot HTML::Object::DOM::Element::Source HTML::Object::DOM::Element::Span HTML::Object::DOM::Element::Style HTML::Object::DOM::Element::TableCaption HTML::Object::DOM::Element::TableCell HTML::Object::DOM::Element::TableCol HTML::Object::DOM::Element::Table HTML::Object::DOM::Element::TableRow HTML::Object::DOM::Element::TableSection HTML::Object::DOM::Element::Template HTML::Object::DOM::Element::TextArea HTML::Object::DOM::Element::Time HTML::Object::DOM::Element::Title HTML::Object::DOM::Element::Track HTML::Object::DOM::Element::UList HTML::Object::DOM::Element::Unknown HTML::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.