-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml-form.html
263 lines (249 loc) · 9.75 KB
/
html-form.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML - Forms Basic 1</title>
<link rel="icon" href="https://raw.githubusercontent.com/coding-dragon/coding-dragon.github.io/master/img/logo.png" type="image/x-icon">
<link rel="stylesheet" href="main.css">
<style>
input, button {
padding: 5px;
font-size: 17px;
}
button {
background-color: #ffcc34;
border: none;
}
</style>
</head>
<body>
<div class="jumbotron" id="top">
<h2 class="display-3">HTMl Forms Basic Controls</h2>
<p class="lead">
Web forms are a very powerful tool for interacting with users — most commonly they are used for collecting data from users, or allowing them to control a user interface.<br/>
This module will help you master the essentials of web forms.
</p>
</div>
<div class="container p-3 bg-head">
<h3>HTML <form> element</h3>
<p class="lead">
The HTML <b><form></b> element formally defines a form and attributes that determine the form's behavior. Each time you want to create an HTML form, you must start it by using this element, nesting all the contents inside.<br/>
<code>autocomplete</code> - attribute indicates whether input elements can by default have their values automatically completed by the browser. Values are <b>on</b> or <b>off</b><br/><br/>
<br/>
<b>Attributes for form submission</b><br/>
<code>action</code> - the URL that processes the form submission.<br/>
<code>method</code> - the HTTP method to submit the form with. The possible values are <b>POST</b> form data sent as the request body and <b>GET</b> form data appended to the action URL with a ? separator.
</p>
<div class="code">
<pre>
<span><form action="" menthod="GET" ></span>
form input elements
<span></form></span></pre>
</div>
</div>
<br/>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h3>HTML <label> element</h3>
<p class="lead">
The HTML <b><label></b> element represents a caption for an item in a user interface.<br/>
The label text is not only visually associated with its corresponding text input; it is programmatically associated with it too. With <code>for</code> attributes we can given gorm element id value to define it.<br/>
<br/>
</p>
<div class="code">
<pre>
<form>
<span><label for="" ></span>Input 1 label name<span></label></span>
form input 1 element
</form></pre>
</div>
</div>
<br/>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h3>Text input fields</h3>
<p class="lead">
Text <input> fields are the most basic form widgets.
</p>
<h4>Single line text fields</h4>
<p class="lead">
A single line text field is created using an <b><input></b> element whose <code>type</code> attribute value is set to <b>text</b>. Attribute <code>placeholder</code> retain the information text for that field and <code>value</code> is current value of the form control.
</p>
<div class="code">
<pre>
<form>
<label for="name">Name: </label>
<span><input type="text" id="name" placeholder="input text field" ></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form>
<label for="name">Name: </label>
<input type="text" id="name" placeholder="input text field" value="" >
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h4>Password field</h4>
<p class="lead">
A Password field is created using an <b><input></b> element whose <code>type</code> attribute value is set to <b>password</b>. The Password field obscure the value entered into the field so it can't be easily read by others.
</p>
<div class="code">
<pre>
<form>
<label for="password">Password: </label>
<span><input type="password" id="password" value="mypassword" ></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form>
<label for="password">Password: </label>
<input type="password" id="password" value="mypassword" >
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h4>Hidden field</h4>
<p class="lead">
A Hidden field is created using an <b><input></b> element whose <code>type</code> attribute value is set to <b>hidden</b>. This is used to create a form control that is invisible to the user, but is still sent to the server along with the rest of the form data once submitted
</p>
<div class="code">
<pre>
<form>
<span><input type="hidden" name="timestamp" value="1286705410"></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form>
<input type="hidden" name="timestamp" value="1286705410" >
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h3>Checkable items: checkboxes and radio buttons</h3>
<p class="lead">
Checkable items are controls whose state you can change by clicking on them or their associated labels. There are two kinds of checkable item: the check box and the radio button.
</p>
<h4>Checkbox</h4>
<p class="lead">
Checkboxes let a user select ZERO or MORE options of a limited number of choices.<br/>
Checkboxe is created using an <b><input></b> element whose <code>type</code> attribute value is set to <b>checkbox</b>. Including the <code>checked</code> attribute makes the checkbox checked automatically when the page loads. Clicking the checkbox or its associated label toggles the checkbox on and off.
</p>
<div class="code">
<pre>
<form>
<label for="red">Red: </label>
<span><input type="checkbox" id="red" name="redcolor" checked></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form>
<p>Choose your colors</p>
<label for="red">Red: </label>
<input type="checkbox" id="red" name="redcolor" checked>
<label for="blue">Blue: </label>
<input type="checkbox" id="blue" name="bluecolor" >
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h4>Radio buttons</h4>
<p class="lead">
Radio buttons let a user select ONLY ONE of a limited number of choices.<br/>
Radio button field is created using an <b><input></b> element whose <code>type</code> attribute value is set to <b>radio</b>. Including the <code>checked</code> attribute makes the radio button checked automatically when the page loads. Clicking the radio button or its associated label toggles the radio button on and off.
</p>
<div class="code">
<pre>
<form>
<label for="red">Red: </label>
<span><input type="checkbox" id="red" name="redcolor" checked></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form>
<p>What is your favorite meal?</p>
<label for="soup">Soup</label>
<input type="radio" id="soup" name="meal" value="soup">
<label for="pizza">Pizza</label>
<input type="radio" id="pizza" name="meal" value="pizza" checked>
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h3>Form buttons</h3>
<p class="lead">
The radio button isn't actually a button, despite its name.
</p>
<h4>Submit Button</h4>
<p class="lead">
Sends the form data to the server.<br/>
For button <b><button></b> element whose <code>type</code> attribute value is set to <b>submit</b>.
</p>
<div class="code">
<pre>
<form>
<span><button type="submit" ></span>Submit <span></button></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form autocomplete="off">
<input type="text" name="name" placeholder="Name">
<button type="submit" >Submit </button>
</form>
</div>
<hr/>
<br/>
<br/>
<div class="container p-3 bg-head">
<h4>Reset Button</h4>
<p class="lead">
Sends the form data to the server.<br/>
For button <b><button></b> element whose <code>type</code> attribute value is set to <b>submit</b>.
</p>
<div class="code">
<pre>
<form>
<span><button type="reset" ></span>Submit <span></button></span>
</form></pre>
</div>
</div>
<br/>
<div class="container">
<form autocomplete="off">
<input type="text" name="name" placeholder="Name">
<button type="reset" >Reset </button>
</form>
</div>
<hr/>
<br/>
<br/>
</body>
</html>