-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTML5 FORMS.txt
More file actions
340 lines (222 loc) · 12.3 KB
/
Copy pathHTML5 FORMS.txt
File metadata and controls
340 lines (222 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
The <form> Element defines a form that is used to collect user input.
<form>
form elements etc,,,,
</form>
Attribute Value Description
accept-charset character_set Specifies the character encodings that are to be used for the form submission
action URL Specifies where to send the form-data when a form is submitted
autocomplete onoff Specifies whether a form should have autocomplete on or off
enctype application/x-www-form-urlencoded
multipart/form-data
text/plain Specifies how the form-data should be encoded when submitting it to the server (only for method="post")
method getpost Specifies the HTTP method to use when sending form-data
name text Specifies the name of a form
novalidate novalidate Specifies that the form should not be validated when submitted
target _blank
_self
_parent
_top Specifies where to display the response that is received after submitting the for
____________________________________________________________
FORM ATTRIBUTES:-
<form action="/action_page.php" accept-charset="ISO-8859-1">
<form action="/action_page.php">
in another words:-Where to send the form-data when the form is submitted.
An absolute URL - points to another web site (like action="http://www.example.com/example.htm")
A relative URL - points to a file within a web site (like action="example.htm")
<form action="/action_page.php" autocomplete="on">
<form action="/action_page_binary.asp" enctype="multipart/form-data">
Definition and Usage
The enctype attribute specifies how the form-data should be encoded when submitting it to the server.
Note: The enctype attribute can be used only if method="post".
Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
multipart/form-data No characters are encoded. This value is required when you are using forms that have a file upload control
text/plain Spaces are converted to "+" symbols, but no special characters are encoded
get Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
<form action="/action_page.php" method="get">
post Sends the form-data as an HTTP post transaction
<form action="/action_page.php" method="post">
The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.
in head section java script can use this name:
<form action="/action_page.php" method="get" name="myForm">
<form action="/action_page.php" novalidate>
<form action="/action_page.php" method="get" target="_blank">
_________________________________________________
HTML Form Elements:-
Tag Description
<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<label> Defines a label for an <input> element
<fieldset> Groups related elements in a form
<legend> Defines a caption for a <fieldset> element
<select> Defines a drop-down list
<optgroup> Defines a group of related options in a drop-down list
<option> Defines an option in a drop-down list
<button> Defines a clickable button
<datalist> Specifies a list of pre-defined options for input controls
<output> Defines the result of a calculation
_________________________________________________________
HTML <textarea> </textarea>
Definition and Usage
The <textarea> tag defines a multi-line text input control.
A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
The size of a text area can be specified by the cols and rows attributes, or even better; through CSS' height and width properties.
<textarea rows="4" cols="50">
Attribute Value Description
autofocus autofocus Specifies that a text area should automatically get focus when the page loads
cols number Specifies the visible width of a text area
dirname textareaname.dir Specifies that the text direction of the textarea will be submitted
disabled disabled Specifies that a text area should be disabled
form form_id Specifies one or more forms the text area belongs to
maxlength 10 Specifies the maximum number of characters allowed in the text area
name text Specifies a name for a text area
placeholder text Specifies a short hint that describes the expected value of a text area
readonly readonly Specifies that a text area should be read-only
required required Specifies that a text area is required/must be filled out
rows number Specifies the visible number of lines in a text area
wrap hard/soft Specifies how the text in a text area is to be wrapped when submitted in a form
__________________________________________________________
HTML <label> Tag
The <label> tag defines a label for a <button>, <input>, <meter>, <output>, <progress>, <select>, or <textarea> element.
Tip: A label can be bound to an element either by using the "for" attribute, or by placing the element inside the <label> element.
<label for="male">Male</label>
<input type="radio" name="gender" id="male" value="male"><br>
<label for="male" form="form1">Male</label> outside form label
_____________________________________________
HTML <fieldset> Tag
Tip: The <legend> tag defines a caption for the <fieldset> element.
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
Attribute Value Description
disabled disabled Specifies that a group of related form elements should be disabled
form form_id Specifies one or more forms the fieldset belongs to
name text Specifies a name for the fieldset
_________________________
HTML <select> Tag
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Attribute Value Description
autofocua autofocus Specifies that the drop-down list should automatically get focus when the page loads
disabled disabled Specifies that a drop-down list should be disabled
form form_id Defines one or more forms the select field belongs to
multiple multiple Specifies that multiple options can be selected at once
name name Defines a name for the drop-down list
required required Specifies that the user is required to select a value before submitting the form
size 5 Defines the number of visible options in a drop-down list
__________________________________________________
HTML <optgroup> Tag
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
Attribute Value Description
disabled disabled Specifies that an option-group should be disabled
label text Specifies a label for an option-group
__________________________________________________
HTML <option> Tag
<select name="cars">
<option value="volvo">Volvo XC90</option>
<option value="saab">Saab 95</option>
<option value="mercedes">Mercedes SLK</option>
<option value="audi">Audi TT</option>
</select>
disabled disabled Specifies that an option should be disabled
label text Specifies a shorter label for an option
selected selected Specifies that an option should be pre-selected when the page loads
value text Specifies the value to be sent to a server
Note: The <option> tag can be used without any attributes, but you usually need the value attribute, which indicates what is sent to the server.
Tip: If you have a long list of options, you can group related options with the <optgroup> tag.
_________________________________________________
HTML <button> Tag
Note: If you use the <button> element in an HTML form, different browsers may submit different values.
Use <input> to create buttons in an HTML form.
Value Description
button The button is a clickable button
submit The button is a submit button (submits form-data)
reset The button is a reset button (resets the form-data to its initial values)
<button name="subject" type="submit" value="fav_CSS">CSS</button>
Attribute Value Description
autofocus autofocus Specifies that a button should automatically get focus when the page loads
disabled disabled Specifies that a button should be disabled
form form_id Specifies one or more forms the button belongs to
formaction URL Specifies where to send the form-data when a form is submitted. Only for type="submit"
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain Specifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethod get/post Specifies how to send the form-data (which HTTP method to use). Only fortype="submit"
formnovalidate formnovalidaate Specifies that the form-data should not be validated on submission. for type submit
formtarget _blank
_self
_parent
_top
framename Specifies where to display the response after submitting the form. Only for type="submit"
name name Specifies a name for the button
type button/reset/submit Specifies the type of button
value text Specifies an initial value for the button
______________________________________________
HTML <datalist> Tag
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
_______________________________________
The <output> tag represents the result of a calculation (like one performed by a script)
HTML <output> Tag
<body>
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" id="a" value="50">100
+<input type="number" id="b" value="50">
=<output name="x" for="a b"></output>
</form>
<p><strong>Note:</strong> The output element is not supported in Edge 12 or Internet Explorer and earlier versions.</p>
</body>
Attribute Value Description
for element_id Specifies the relationship between the result of the calculation, and the elements used in the calculation
form form_id Specifies one or more forms the output element belongs to
name name Specifies a name for the output element
_______________________________________________________
HTML Input Types
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
__________________________