Skip to content

Commit c375c21

Browse files
authored
Add files via upload
1 parent ceecf1e commit c375c21

File tree

6 files changed

+447
-243
lines changed

6 files changed

+447
-243
lines changed

Form-Controls/README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
# Form Controls
2-
3-
## Learning Objectives
4-
5-
<!--{{<objectives>}}>-->
6-
7-
- [ ] Interpret requirements and check against a list of criteria
8-
- [ ] Write a valid form
9-
- [ ] Test with Devtools
10-
- [ ] Refactor using Devtools
11-
<!--{{<objectives>}}>-->
12-
13-
## Task
14-
15-
We are selling t-shirts. Write a form to collect the following data:
16-
17-
Our customers already have accounts, so we know their addresses and charging details already. We don't need to collect that data. We want to confirm they are the right person, then get them to choose a colour and size.
18-
19-
Writing that out as a series of questions to ask yourself:
20-
21-
1. What is the customer's name? I must collect this data, and validate it. But what is a valid name? I must decide something.
22-
2. What is the customer's email? I must make sure the email is valid. Email addresses have a consistent pattern.
23-
3. What colour should this t-shirt be? I must give 3 options. How will I make sure they don't pick other colours?
24-
4. What size does the customer want? I must give the following 6 options: XS, S, M, L, XL, XXL
25-
26-
All fields are required.
27-
Do not write a form action for this project.
28-
29-
## Developers must test their work.
30-
31-
Let's write out our testable criteria. Check each one off as you complete it.
32-
33-
- [ ] I have used HTML only.
34-
- [x] I have not used any CSS or JavaScript.
35-
36-
### HTML
37-
38-
- [ ] My form is semantic html.
39-
- [ ] All inputs have associated labels.
40-
- [ ] My Lighthouse Accessibility score is 100.
41-
- [ ] I require a valid name. I have defined a valid name as a text string of two characters or more.
42-
- [ ] I require a valid email.
43-
- [ ] I require one colour from a defined set of 3 colours.
44-
- [ ] I require one size from a defined set of 6 sizes.
45-
46-
## Resources
47-
48-
- [MDN: Form controls](https://developer.mozilla.org/en-US/docs/Learn/Forms)
49-
- [MDN: Form validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation)
50-
- [Lighthouse](https://developers.google.com/web/tools/lighthouse)
51-
- [Lighthouse Guide](https://programming.codeyourfuture.io/guides/testing/lighthouse)
1+
# Form Controls
2+
3+
## Learning Objectives
4+
5+
<!--{{<objectives>}}>-->
6+
7+
- [ ] Interpret requirements and check against a list of criteria
8+
- [ ] Write a valid form
9+
- [ ] Test with Devtools
10+
- [ ] Refactor using Devtools
11+
<!--{{<objectives>}}>-->
12+
13+
## Task
14+
15+
We are selling t-shirts. Write a form to collect the following data:
16+
17+
Our customers already have accounts, so we know their addresses and charging details already. We don't need to collect that data. We want to confirm they are the right person, then get them to choose a colour and size.
18+
19+
Writing that out as a series of questions to ask yourself:
20+
21+
1. What is the customer's name? I must collect this data, and validate it. But what is a valid name? I must decide something.
22+
2. What is the customer's email? I must make sure the email is valid. Email addresses have a consistent pattern.
23+
3. What colour should this t-shirt be? I must give 3 options. How will I make sure they don't pick other colours?
24+
4. What size does the customer want? I must give the following 6 options: XS, S, M, L, XL, XXL
25+
26+
All fields are required.
27+
Do not write a form action for this project.
28+
29+
## Developers must test their work.
30+
31+
Let's write out our testable criteria. Check each one off as you complete it.
32+
33+
- [ ] I have used HTML only.
34+
- [x] I have not used any CSS or JavaScript.
35+
36+
### HTML
37+
38+
- [ ] My form is semantic html.
39+
- [ ] All inputs have associated labels.
40+
- [ ] My Lighthouse Accessibility score is 100.
41+
- [ ] I require a valid name. I have defined a valid name as a text string of two characters or more.
42+
- [ ] I require a valid email.
43+
- [ ] I require one colour from a defined set of 3 colours.
44+
- [ ] I require one size from a defined set of 6 sizes.
45+
46+
## Resources
47+
48+
- [MDN: Form controls](https://developer.mozilla.org/en-US/docs/Learn/Forms)
49+
- [MDN: Form validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation)
50+
- [Lighthouse](https://developers.google.com/web/tools/lighthouse)
51+
- [Lighthouse Guide](https://programming.codeyourfuture.io/guides/testing/lighthouse)

Form-Controls/index.html

Lines changed: 199 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,199 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6-
<title>My form exercise</title>
7-
<meta name="description" content="" />
8-
<meta name="viewport" content="width=device-width, initial-scale=1" />
9-
</head>
10-
<body>
11-
<header>
12-
<h1>Product Pick</h1>
13-
</header>
14-
<main>
15-
<form>
16-
<!-- write your html here-->
17-
<!--
18-
try writing out the requirements first as comments
19-
this will also help you fill in your PR message later-->
20-
</form>
21-
</main>
22-
<footer>
23-
<!-- change to your name-->
24-
<h2>By HOMEWORK SOLUTION</h2>
25-
</footer>
26-
</body>
27-
</html>
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible"content="ie=edge">
7+
<title>Form</title>
8+
</head>
9+
<body>
10+
<form method="GET" enctype="multipart/form-data">
11+
<div>
12+
<label for="name">Name</label>
13+
<input type="text" name="name" id="name" required>
14+
<div>
15+
<div>
16+
<label for="email">Email</label>
17+
<input type="email" name="email" id="email" required>
18+
<div>
19+
</div>
20+
<label for="age">Age</label>
21+
<input type="number" name="age" id="age" min="1" max="200" step="5">
22+
<div>
23+
</div>
24+
<label for="date">Birthdate</label>
25+
<input type="date" name="date" id="date" min="2019-06-10">
26+
<div>
27+
</div>
28+
Favorite Food
29+
<div>
30+
<label for="banana">Banana</label>
31+
<input type="checkbox" name="banana" id="banana">
32+
</div>
33+
<div>
34+
<label for="apple">Apple</label>
35+
<input type="checkbox" name="apple" id="apple">
36+
</div>
37+
<div>
38+
<div>
39+
Gender
40+
</div>
41+
<label for="male">Male</label>
42+
<input type="radio" name="gender" id="male" value="male">
43+
<div>
44+
<div>
45+
<label for="female">Female</label>
46+
<input type="radio" name="gender" id="female" value="female">
47+
<div>
48+
</div>
49+
<div>
50+
<label for="eyeColor">Eye Color</label>
51+
<select NAME="eyeColor" id="eyeColor" multiple>
52+
<option value="Green">Green</option>
53+
<option label="Red" value="Red"></option>
54+
<option value="Pink">Pink</option>
55+
</select>
56+
<div>
57+
</div>
58+
<label for="bio">Bio</label>
59+
<textarea id="bio" name="bio"></textarea>
60+
<div>
61+
<input type="hidden" name="hidden" value="hi">
62+
</div>
63+
<label for="file">File</label>
64+
<input id="file" type="file" name="file">
65+
<div>
66+
</div>
67+
<label for="phone">Phone</label>
68+
<input type="tel" name="phone" id="phone">
69+
<div>
70+
</div>
71+
<label for="url">URL</label>
72+
<input type="url" name="url" id="url">
73+
<div>
74+
</div>
75+
<label for="color">Color</label>
76+
<input type="color" name="color" id="color">
77+
<div>
78+
</div>
79+
<label>
80+
Password
81+
<input type="password" name="password" required>
82+
<label>
83+
<div>
84+
<Button type="reset">Reset</Button>
85+
<button type="submit "y5>Submit</button>
86+
</form>
87+
<!-- Code injected by live-server -->
88+
<script>
89+
// <![CDATA[ <-- For SVG support
90+
if ('WebSocket' in window) {
91+
(function () {
92+
function refreshCSS() {
93+
var sheets = [].slice.call(document.getElementsByTagName("link"));
94+
var head = document.getElementsByTagName("head")[0];
95+
for (var i = 0; i < sheets.length; ++i) {
96+
var elem = sheets[i];
97+
var parent = elem.parentElement || head;
98+
parent.removeChild(elem);
99+
var rel = elem.rel;
100+
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
101+
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
102+
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
103+
}
104+
parent.appendChild(elem);
105+
}
106+
}
107+
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
108+
var address = protocol + window.location.host + window.location.pathname + '/ws';
109+
var socket = new WebSocket(address);
110+
socket.onmessage = function (msg) {
111+
if (msg.data == 'reload') window.location.reload();
112+
else if (msg.data == 'refreshcss') refreshCSS();
113+
};
114+
if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
115+
console.log('Live reload enabled.');
116+
sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
117+
}
118+
})();
119+
}
120+
else {
121+
console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
122+
}
123+
// ]]>
124+
</script>
125+
</body>
126+
</html>
127+
<style>
128+
body {
129+
font-family: Arial, sans-serif;
130+
background-color: #f4f4f4;
131+
padding: 20px;
132+
}
133+
134+
form {
135+
background-color: #fff;
136+
padding: 20px;
137+
border-radius: 8px;
138+
max-width: 500px;
139+
margin: 0 auto;
140+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
141+
}
142+
143+
form div {
144+
margin-bottom: 15px;
145+
}
146+
147+
label {
148+
display: block;
149+
margin-bottom: 5px;
150+
font-weight: bold;
151+
}
152+
153+
input[type="text"],
154+
input[type="email"],
155+
input[type="number"],
156+
input[type="date"],
157+
input[type="tel"],
158+
input[type="url"],
159+
input[type="color"],
160+
input[type="password"],
161+
select,
162+
textarea {
163+
width: 100%;
164+
padding: 8px;
165+
box-sizing: border-box;
166+
border-radius: 4px;
167+
border: 1px solid #ccc;
168+
}
169+
170+
input[type="checkbox"],
171+
input[type="radio"] {
172+
margin-right: 5px;
173+
}
174+
175+
select[multiple] {
176+
height: 100px;
177+
}
178+
179+
button {
180+
padding: 10px 20px;
181+
border: none;
182+
background-color: #4285f4;
183+
color: white;
184+
border-radius: 4px;
185+
cursor: pointer;
186+
margin-right: 10px;
187+
}
188+
189+
button[type="reset"] {
190+
background-color: #ccc;
191+
color: #000;
192+
}
193+
194+
button:hover {
195+
opacity: 0.9;
196+
}
197+
</style>
198+
199+

0 commit comments

Comments
 (0)