For an alternate method to associate a <{label}> with a form control, please refer to the
label's <{label/for}> attribute.
radio. To make the radio buttons work as a group, they are each given a common name
using the <{input/name}> attribute. To group a batch of controls together, such as, in this
case, the radio buttons, one can use the <{fieldset}> element. The title of such a group of
controls is given by the first element in the <{fieldset}>, which has to be a <{legend}> element.
checkbox:
tel) and
e-mail addresses (<{input}> elements with a <{input/type}> attribute set to code>email)
can be added:
time can be used. Many form controls have attributes to help
authors dictate the values a user can enter; in this case, three attributes of particular
interest are <{input/min}>, <{input/max}>, and <{input/step}>. Respectively, these set the
minimum time, the maximum time, and the interval between allowed values (in seconds).
For this example, the pizzeria only delivers between 11am and 9pm, and allows users to choose a
delivery window in 15 minute increments. As the <{input/min}>, <{input/max}> attributes take
values in 24-hour time, this means the min value would be "11:00" and the
max value would be "21:00". Since the <{input/step}> attribute is set in seconds,
to set the form control to accept values in 15 minute increments, the 15 minutes would need to
be converted to seconds (900 seconds).
https://pizza.example.com/order is configured to accept submissions using the
application/x-www-form-urlencoded format, expecting the following parameters sent
in an HTTP POST body:
: custname
:: Customer's name
: custtel
:: Customer's telephone number
: custemail
:: Customer's e-mail
: size
:: The pizza size, either small or large
: topping
:: A topping, specified once for each selected topping, with the allowed values being
bacon, onion, and mushroom
: delivery
:: The requested delivery time
: comments
:: The delivery instructions
value attribute.
Multiple controls can have the same name; for example, here we give all the checkboxes the same
name, and the server distinguishes which checkbox was checked by seeing which values are submitted
with that name — like the radio buttons, they are also given unique values with the
value attribute.
Given the settings in the previous section, this all becomes:
custname=Denise+Lawrence&custtel=555-555-8642&custemail=&size=small&topping=onion&topping=mushroom&delivery=19%3A00&comments=
When a form is submitted, invalid events are fired at each form control that is
invalid, and then at the <{form}> element itself. This can be useful for displaying a summary
of the problems with the form, since typically the browser itself will only report one problem
at a time.
/find?t=cats&q=fur.
On the other hand, consider this form:
------kYFrd4jNJEgCervE Content-Disposition: form-data; name="t" cats ------kYFrd4jNJEgCervE Content-Disposition: form-data; name="q" fur ------kYFrd4jNJEgCervE--
Consequently, if the default button is disabled, the form is not submitted when such an implicit submission mechanism is used. (A button has no activation behavior when disabled.)
There are pages on the Web that are only usable if there is a way to implicitly submit forms, so user agents are strongly encouraged to support this.
If the form has no <{input/Submit|Submit Button}>, then the implicit submission mechanism must do nothing if the form has more than one field that blocks implicit submission, and must submit the <{form}> element from the <{form}> element itself otherwise. For the purpose of the previous paragraph, an element is a field that blocks implicit submission of a <{form}> element if it is an <{input}> element whose form owner is that <{form}> element and whose <{input/type}> attribute is in one of the following states: <{input/Text}>, <{input/Search}>, <{input/URL}>, <{input/Telephone}>, <{input/E-mail}>, <{input/Password}>, <{input/LocalDateTime|Local Date and Time}>, <{input/Date}>, <{input/Month}>, <{input/Week}>, <{input/Time}>, <{input/Number}>invalid at the form element and then abort these
steps.submit, at form. If the
event's default action is prevented (i.e., if the event is canceled) then abort these steps.
Otherwise, continue (effectively the default action is to perform the submission).| GET | POST | |
|---|---|---|
http
| Mutate action URL | Submit as entity body |
https
| Mutate action URL | Submit as entity body |
ftp
| Get action URL | Get action URL |
javascript
| Get action URL | Get action URL |
data
| Get action URL | Post to data: |
mailto
| Mail with headers | Mail as body |
application/x-www-form-urlencoded encoding algorithm, interpreted as
a US-ASCII string.
Set parsed action's query component to query.
Let destination be a new [=url/URL=] formed by applying the
URL serializer algorithm to parsed action.
Plan to navigate to destination.
: Submit as entity body
:: Let entity body be the result of encoding the form data set using
the appropriate form encoding algorithm.
Let MIME type be determined as follows:
: If enctype is application/x-www-form-urlencoded
:: Let MIME type be "application/x-www-form-urlencoded".
: If enctype is multipart/form-data
:: Let MIME type be the concatenation of the string
"multipart/form-data;", a U+0020 SPACE character,
the string "boundary=",
and the multipart/form-data boundary string generated by the
multipart/form-data encoding algorithm.
: If enctype is text/plain
:: Let MIME type be "text/plain".
Otherwise, plan to navigate to a new request whose [=url/URL=] is
action, method is method, header list
consists of Content-Type/MIME type, and body is
entity body.
: Get action URL
:: Plan to navigate to action.
The form data set is discarded.
: Post to data: :: Let data be the result of encoding the form data set using the appropriate form encoding algorithm. If action contains the string "%%%%"
(four U+0025 PERCENT SIGN characters), then percent encode all bytes in
data that, if interpreted as US-ASCII, are not characters in the URL
default encode set, and then, treating the result as a US-ASCII string,
UTF-8 percent encode all the U+0025 PERCENT SIGN characters in the resulting
string and replace the first occurrence of "%%%%" in action
with the resulting doubly-escaped string. [[!URL]]
Otherwise, if action contains the string "%%"
(two U+0025 PERCENT SIGN characters in a row, but not four), then
UTF-8 percent encode all characters in data that, if interpreted as US-ASCII, are
not characters in the URL default encode set, and then, treating the result as a
US-ASCII string, replace the first occurrence of "%%" in action
with the resulting escaped string. [[!URL]]
Plan to navigate to the potentially modified action (which
will be a data: URL).
: Mail with headers
:: Let headers be the resulting encoding the form data set using the
application/x-www-form-urlencoded encoding algorithm, interpreted as
a US-ASCII string.
Replace occurrences of U+002B PLUS SIGN characters (+) in headers with
the string "%20".
Let destination consist of all the characters from the first character
in action to the character immediately before the first U+003F QUESTION
MARK character (?), if any, or the end of the string if there are none.
Append a single U+003F QUESTION MARK character (?) to destination.
Append headers to destination.
Plan to navigate to destination.
: Mail as body
:: Let body be the resulting of encoding the form data set using the
appropriate form encoding algorithm and then
percent encoding all the bytes in the resulting byte string
that, when interpreted as US-ASCII, are not characters in the URL default encode
set. [[!URL]]
Let destination have the same value as action.
If destination does not contain a U+003F QUESTION MARK character (?),
append a single U+003F QUESTION MARK character (?) to destination.
Otherwise, append a single U+0026 AMPERSAND character (&).
Append the string "body=" to destination.
Append body, interpreted as a US-ASCII string, to destination.
Plan to navigate to destination.
: Submit dialog
:: Let subject be the nearest ancestor <{dialog}> element of form, if any.
If there isn't one, or if it does not have an open
attribute, do nothing. Otherwise, proceed as follows:
If submitter is an <{input}> element whose <{input/type}> attribute is in
the <{input/Image|Image Button}> state, then let result
be the string formed by concatenating the selected coordinate's
x-component, expressed as a base-ten number using ASCII digits, a
U+002C COMMA character (,), and the selected coordinate's y-component,
expressed in the same way as the x-component.
Otherwise, if submitter has a value, then let
result be that value.
Otherwise, there is no result.
Then, close the dialog subject. If there is a result,
let that be the return value.
The appropriate form encoding algorithm is determined as follows:
: If enctype is application/x-www-form-urlencoded
:: Use the application/x-www-form-urlencoded encoding algorithm.
: If enctype is multipart/form-data
:: Use the multipart/form-data encoding algorithm.
: If enctype is text/plain
:: Use the text/plain encoding algorithm.
type IDL
attribute of field.value attribute specified, then let value
be the value of that attribute; otherwise, let value be the string "on".application/octet-stream as the type.dirname attribute, and that
attribute's value is not the empty string, then run these substeps:
dirname attribute.ltr" if the
directionality of the element is 'ltr', and "rtl" otherwise (i.e., when the directionality of the element is
'rtl').direction" as the type.
An element can only have a dirname
attribute if it is a <{textarea}> element or an <{input}> element whose
<{input/type}> attribute is in either the <{input/Text}> state or the <{input/Search}> state.
file" or "textarea", replace every occurrence of a U+000D
CARRIAGE RETURN (CR) character not followed by a U+000A LINE FEED (LF) character, and every
occurrence of a U+000A LINE FEED (LF) character not preceded by a U+000D CARRIAGE RETURN (CR)
character, by a two-character string consisting of a U+000D CARRIAGE RETURN U+000A LINE FEED
(CRLF) character pair.
In the case of the value of <{textarea}> elements, this newline normalization is already performed during the conversion of the control's raw value into the control's value (which also performs any necessary line wrapping). In the case of <{input}> elements <{input/type}> attributes in the <{input/File|File Upload}> state, the value is not normalized.
form element has an accept-charset attribute, set
encoding to the return value of running these substeps:
1. Let input be the value of the form element's
accept-charset attribute.
2. Let candidate encoding labels be the result of
splitting input on spaces.
3. Let candidate encodings be an empty list of character encodings.
4. For each token in candidate encoding labels in turn (in the order in which they
were found in input), get an encoding for
the token and, if this does
not result in failure, append the encoding to candidate encodings.
5. If candidate encodings is empty, return UTF-8.
6. Return the first encoding in candidate encodings.
3. Return the result of getting an output encoding from encoding.
application/x-www-form-urlencoded. [[!URL]]
The application/x-www-form-urlencoded encoding algorithm is as follows:
1. Let encoding be the result of picking an encoding for the form.
2. Let serialized be the result of running the
application/x-www-form-urlencoded serializer given
form data set and encoding.
3. Return the result of encoding serialized.
multipart/form-data encoding algorithm is as follows:
_charset_" and its
type is "hidden", replace its value with charset.multipart/form-data, and return
the resulting byte stream. [[!RFC7578]]
Each entry in the form data set is a field, the name of the entry is the
field name and the value of the entry is the field value.
The order of parts must be the same as the order of fields in the form data set.
Multiple entries with the same name must be treated as distinct fields.
The parts of the generated multipart/form-data resource that correspond to
non-file fields must not have a Content-Type header specified. Their names and
values must be encoded using the character encoding selected above.
File names included in the generated multipart/form-data resource (as part of
file fields) must use the character encoding selected above, though the precise name may be
approximated if necessary (e.g., newlines could be removed from file names, quotes could be
changed to "%22", and characters not expressible in the selected character encoding could be
replaced by other characters).
For each character in the entry's file name that cannot be expressed using the selected
character encoding, replace the character by a string consisting of a U+0026 AMPERSAND
character (&), a U+0023 NUMBER SIGN character (#), one or more ASCII digits
representing the code point of the character in base ten, and finally a U+003B SEMICOLON
character (;).
Field names and file names included in the generated multipart/form-data
resource must undergo multipart parameter-value character replacement for syntactically
significant characters: for each character in the parameter value that is U+0022 QUOTATION MARK
("), U+007F DELETE (␡) or any other control in the range U+0000-U+001F except U+001B
ESCAPE (␛), replace the character by a string consisting of a U+0025 PERCENT SIGN character (%)
and two ASCII hex digits representing the code point of the character in base sixteen,
and replace each U+005C REVERSE SOLIDUS character (\) with two consecutive U+005C REVERSE
SOLIDUS characters (\\). U+001B ESCAPE (␛) is preserved (passed through unquoted) for
Web-compatible ISO-2022-JP.
The boundary used by the user agent in generating the return value of this algorithm is the
multipart/form-data boundary string. (This value is used to generate the
MIME type of the form submission payload generated by this algorithm.)
multipart/form-data payloads, see RFC 7578. [[!RFC7578]]
text/plain encoding algorithm is as follows:
_charset_" and its type
is "hidden", replace its value with charset.file", replace its value with the file's
name only.text/plain format are intended to be human readable. They are
not reliably interpretable by computer, as the format is ambiguous (for example, there is no way
to distinguish a literal newline in a value from the newline at the end of the value).
reset, that bubbles and is cancelable, at form, and then, if that event is not canceled, must invoke the reset algorithm of each resettable element whose form owner is form.
When the reset algorithm is invoked by the reset() method, the reset event
fired by the reset algorithm must not be trusted.
Each resettable element defines its own reset algorithm. Changes made to form controls as part of
these algorithms do not count as changes caused by the user (and thus, e.g., do not cause input events to fire).