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
8 changes: 4 additions & 4 deletions Form-Controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@

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.
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 color 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 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?
3. What color should this t-shirt be? I must give 3 options. How will I make sure they don't pick other colors?
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.

## 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.

Expand All @@ -40,7 +40,7 @@ Let's write out our testable criteria. Check each one off as you complete it.
- [ ] 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 color from a defined set of 3 colors.
- [ ] I require one size from a defined set of 6 sizes.

## Resources
Expand Down
46 changes: 42 additions & 4 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,60 @@
<title>My form exercise</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<h1>Product Pick</h1>
</header>
<main>
<form>
<!-- write your html here-->
<p> please enter the required (*) information to order your T-shirt. </p>
<fieldset>
<legend>Customer Information</legend>
<label for="name">Name:*</label>
<input type="text" id="name" name="name" required pattern="[A-za-z/s]{2,50}"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this regular expression, [A-za-z/s]{2,50}, mean? That is, what kind of strings are acceptable? Have you tested the input field to see if the form accepts/rejects the value you expect?

Currently, when an input is rejected, the user is not given any explanation as to why.
Could you make the form more accessible by providing clear feedback so users can understand why their input was rejected?

<br />
<label for="email">Email:*</label>
<input type="email" id="email" name="email" required />
</fieldset>

<!--
try writing out the requirements first as comments
this will also help you fill in your PR message later-->
customer name, with validation
customer's email
---- The upper one customer information-----
//
---- The lower one product information-----
color of T-shire (choose one from 3 option)
size of T-shirt (choose one from xs, s, m, l, xl,xxl)-->
<fieldset>
<legend>Product Information</legend>
<label for="color">Color:*</label>
<select id="color" name="color" required>
<option value="">--Please choose a color--</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
<br />
<label for="size">Size:*</label>
<select id="size" name="size" required>
<option value="">--Please choose a 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>
</fieldset>
<label for ="submit"></label>
<input type="submit" id="submit" value="Submit Order"/>
</form>
</main>
<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>By Dagim Daniel</p>
</footer>
</body>
</html>
42 changes: 42 additions & 0 deletions Form-Controls/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:root {
--paper: oklch(7 0 0);
--ink: color-mix(in oklab, var(--color) 5%, black);
--font: 100%/1.5 system-ui;
--space: clamp(6px, 6px + 2vw, 15px);
--line: 1px solid;
--container: 1280px;
Comment on lines +2 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete any unused custom properties to keep the code clean?

}
/* ====== Base Elements ======
General rules for basic HTML elements in any context */
body {
background: var(--paper);
color: var(--ink);
font: var(--font);
}
/* ====== Site Layout ======
Setting the overall rules for page regions
https://www.w3.org/WAI/tutorials/page-structure/regions/
*/
body {
max-width: var(--container);
margin: 0 auto calc(var(--space) * 4) auto;
}
h1 {

text-align: center;
}
fieldset{
padding:var (--space);
max-width:100%;
}
input :invalid
{
border-color:red;
}
footer{
background-image: linear-gradient(to right, grey, lightgreen);
width:var(--container);
position: fixed;
bottom: 0;
text-align: center;
}