Lecture 04
Lecture 04
Type Description
• <input type="reset"> defines a reset button that will reset all form values to their default values:
• <input type="button"> defines a button:
The Action Attribute
• The action attribute defines the action to be performed when the form is
submitted.
• Normally, the form data is sent to a web page on the server when the user clicks
on the submit button.
• Note: If the action attribute is omitted, the action is set to the current page.
The Method Attribute
The method attribute specifies the HTTP method (GET or POST) to be used when
submitting the form data:
When to Use GET?
Always use POST if the form data contains sensitive or personal information. The
POST method does not display the submitted form data in the page address field.
Notes on POST:
• POST has no size limitations, and can be used to send large amounts of data.
• Form submissions with POST cannot be bookmarked
The Name Attribute
This example will only submit the "Last name" input field:
Input Type Checkbox
• The rows attribute specifies the visible number of lines in a text area.
• The cols attribute specifies the visible width of a text area
HTML5 <datalist> Element
• The <datalist> element specifies a list of pre-defined options for an <input> element.
• Users will see a drop-down list of the pre-defined options as they input data.
• The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.
Grouping Form Data with <fieldset>
• The <input type="file"> defines a file-select field and a "Browse" button for file
uploads
HTML Input Attributes
With a maxlength attribute, the input field will not accept more than the allowed number of
characters.
The autocomplete Attribute
• The autocomplete attribute specifies whether a form or input field should have
autocomplete on or off.
• When autocomplete is on, the browser automatically completes the input values
based on values that the user has entered before.
The autofocus Attribute
• The autofocus attribute specifies that the input field should automatically get
focus when the page loads.
The list Attribute
• The list attribute refers to a <datalist> element that contains pre-defined options
for an <input> element.
The multiple Attribute
• The multiple attribute specifies that the user is allowed to enter more than one
value in the <input> element.
• The multiple attribute works with the following input types: email, and file.
The placeholder Attribute
• The placeholder attribute specifies a hint that describes the expected value of an
input field.
• The hint is displayed in the input field before the user enters a value.
• The placeholder attribute works with the following input types: text, search, url,
tel, email, and password.
The required Attribute
• The required attribute specifies that an input field must be filled out before
submitting the form.
The HTML <video> Element
• To show a video in HTML, use the <video> element:
The HTML <audio> Element
• To play an audio file in HTML, use the <audio> element: