Académique Documents
Professionnel Documents
Culture Documents
2016.03.16
Forms
o Form
o form
o Form-
o
o
o
o
o
o
o
o
o
o
, ,
.
HTML5
,
.
2
.
1.
2.
HMTL .
An application of script on the web server that processes the
information collected by the form and returns an appropriate
response.
When the browser encodes the data gathered from the previous
slide to the server, it looks like this. You dont need to worry
about this, the browser handles it automatically.
POST: browser sends a separate server request containing some special headers
followed by the data. Only the server sees the content of this request.
7
GET: The data gets tacked right onto the URL sent to the server.
FORM CONTROLS
o
When a user enters a comment in the filed (This is the best band
ever!), it would be passed to the server as a name/value pair like
this.
One of the most common form input types is the text entry field
used for entering a single word or line of text. Add a text input
field to a form with the input element with its type attribute set
to text, as shown here.
The value attribute : specifies default text that appears in the filed
when the form is loaded.
o The maxlength attribute : by default, users can type an unlimited
number of characters in a text field. You can set a maximum character
limit using this attribute.
o
When you want users to be able enter more than one line of text,
use the textarea (<textarea></textarea>) element.
You can put content between tags and it will show up in the text box
when the form is displayed. It will also get sent to server when the
form is submitted, so carefully consider what goes there. Also, the new
HTML5 placeholder attribute can be used with textarea to provide a
short hint of how to fill in the field.
o The cols and rows attributes are a way of specifying the size of the
textarea using markup, but it is more commonly sized with CSS.
o The maxlength attribute sets a limit on the number of characters.
o
10
11
In HTML5, the email, tel, url, and search input types let the
browser know what type of information to expect in the field.
Not all browsers support them or support them in the same way.
12
13
REGULAR EXPRESSION
o
14
REGULAR EXPRESSION
o
Other examples
15
16
When one radio button is on, all of the others must be off.
Radio buttons are added to a form using the input element with
the type attribute set to radio.
To bind multiple radio inputs into set, you use their name
attributes set to the same value.
o
You can decide which button is checked when the form loads by
adding the checked attribute to the input element.
17
18
The content of the chosen option element is what gets passed to the
server. If you want to send a different value, use the value attribute.
19
20
21
o
o
The file selection control makes it possible for users to select a document from
the hard drive to be submitted with the form data.
It is added to the form using the input element with its type set to file.
When a form contains a file selection input element, you must specify the
enctype attribute of the form as multipart/form-data and also use the POST
method.
To permit multiple file uploads, well need to add the multiple attribute.
We can also restrict what files can be uploaded in the browser with the accept
22
attribute.
HTML5 introduces 6 input types that make date and time selection
widgets part of a browsers standard built-in display capabilities.
1.
23
24
25
26
27
There are the following useful attributes that applies to the most of
form controls
Required (HTML5): By adding this, we were asking the browser
to make sure this field has been filled out before submitting.
28
29