Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Form-Controls/Form Control Lighthouse score.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 16 additions & 32 deletions Form-Controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,44 @@
- [ ] Write a valid form
- [ ] Test with Devtools
- [ ] Refactor using Devtools
- [ ] Use version control by committing often and pushing regularly to GitHub
- [ ] Develop the habit of writing clean, well-structured, and error-free code
<!--{{<objectives>}}>-->

## Task

We are selling T-shirts. Write a form to collect the following data:
We are selling t-shirts. Write a form to collect the following data:

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.

Writing that out as a series of questions to ask yourself:

1. What is the customer's name? I must collect this data and ensure it contains at least two non-space characters.
2. What is the customer's email? I must make sure the email is valid. Email addresses follow a consistent pattern.
3. What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours?
4. What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL
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.
2. What is the customer's email? I must make sure the email is valid. Email addresses have a consistent pattern.
3. What colour should this t-shirt be? I must give 3 options. How will I make sure they don't pick other colours?
4. What size does the customer want? I must give the following 6 options: XS, S, M, L, XL, XXL

All fields are required.
Do not write a form action for this project.

## Acceptnce Criteria

### Developers must test their work.
## Developers must test their work.

Let's write out our testable criteria. Check each one off as you complete it.

- [ ] I have only used HTML and CSS.
- [ ] I have not used any JavaScript.
- [] I have only used HTML and CSS.
- [] I have not used any JavaScript.

### HTML

- [ ] My form is semantic HTML.
- [ ] All inputs have associated labels.
- [ ] My Lighthouse Accessibility score is 100.
- [ ] I require a valid name.
- [ ] I require a valid email.
- [ ] I require one colour from a defined set of 3 colours.
- [ ] I require one size from a defined set of 6 sizes.

### Developers must adhere to professional standards.

> Before you say you're done: Is your code readable? Does it run correctly? Does it look professional?

These practices reflect the level of quality expected in professional work.
They ensure your code is reliable, maintainable, and presents a polished, credible experience to users.

- [ ] My HTML code has no errors or warnings when validated using https://validator.w3.org/
- [ ] My code is consistently formatted
- [ ] My page content is free of typos and grammatical mistakes
- [ ] I commit often and push regularly to GitHub
- [✅] My form is semantic html.
- [✅] All inputs have associated labels.
- [✅] My Lighthouse Accessibility score is 100.
- [✅] I require a valid name. I have defined a valid name as a text string of two characters or more.
- [✅] I require a valid email.
- [✅] I require one colour from a defined set of 3 colours.
- [✅] I require one size from a defined set of 6 sizes.

## Resources

- [MDN: Form controls](https://developer.mozilla.org/en-US/docs/Learn/Forms)
- [MDN: Form validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation)
- [Lighthouse](https://developers.google.com/web/tools/lighthouse)
- [Lighthouse Guide](https://programming.codeyourfuture.io/guides/testing/lighthouse)
- [Format Code and Make Logical Commits in VS Code](../practical_guide.md)
98 changes: 93 additions & 5 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>My form exercise</title>
<link rel="stylesheet" href="style.css">
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
Expand All @@ -13,15 +14,102 @@ <h1>Product Pick</h1>
</header>
<main>
<form>
<!-- write your html here-->
<!--
try writing out the requirements first as comments
this will also help you fill in your PR message later-->

<!--
T-SHIRT ORDER FORM REQUIREMENTS

- Only HTML and CSS (no JavaScript)
- Semantic HTML structure
- All inputs must have associated labels
- Accessibility should be high (Lighthouse target: 100)

DATA TO COLLECT:

1. Customer Name
- Required
- Must be at least 2 characters

2. Customer Email
- Required
- Must be a valid email format

3. T-shirt Colour
- Required
- Must choose ONE from 3 options:
• Black
• White
• Blue

4. T-shirt Size
- Required
- Must choose ONE from 6 options:
• XS
• S
• M
• L
• XL
• XXL

NOTES:
- Do NOT include a form action
- All fields must be required
-->
<!-- Name -->
<label for="name">Name:</label>
<input
type="text"
id="name"
name="name"
minlength="2"
required
>

<br><br>

<!-- Email -->
<label for="email">Email:</label>
<input
type="email"
id="email"
name="email"
required
>

<br><br>

<!-- Colour -->
<label for="colour">Choose Colour:</label>
<select id="colour" name="colour" required>
<option value="">Select Colour</option>
<option value="black">Black</option>
<option value="white">White</option>
<option value="blue">Blue</option>
</select>

<br><br>

<!-- Size -->
<label for="size">Choose Size:</label>
<select id="size" name="size" required>
<option value="">Select Size</option>
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
</select>

<br><br>

<button type="submit">Submit Order</button>


</form>
</main>
<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>By SHAFIEK WALKER</p>
</footer>
</body>
</html>
40 changes: 40 additions & 0 deletions Form-Controls/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 40px;
}

h1 {
text-align: center;
}

p {
text-align: center;
}

form {
background-color: white;
max-width: 400px;
margin: 0 auto;
padding: 24px;
border-radius: 12px;
box-shadow: inset 0 0 0 2px #ccc;
}

label {
font-weight: bold;
}

input,
select,
button {
width: 100%;
padding: 10px;
margin-top: 6px;
margin-bottom: 16px;
box-sizing: border-box;
}

button {
cursor: pointer;
}
Loading