Skip to content
Open
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
120 changes: 117 additions & 3 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,136 @@
<title>My form exercise</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
Comment on lines +9 to +10
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How could you seperate the code for the styling from the html to make it easier to review (because of smaller files with seperate responsibilites)

font-family: system-ui, sans-serif;
padding: 1rem;
line-height: 1.5;
}
form {
max-width: 500px;
margin: auto;
}
fieldset {
border: none;
padding: 0;
margin: 1.5rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
input, select button{
width: 100%;
padding:12px;
font-size: 1rem;
min-height: 48px;
box-sizing: border-box;
}
small {
display: block;
margin-top: 0.25rem;
color: #666;
}
button {
padding: 0.75rem 1.5rem;
font-size: 1rem;
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
header, footer {
text-align: center;
margin-bottom: 2rem;
}
footer p {
font-size: 0.875rem;
color: #666;
}

</style>
</head>
<body>
<header>
<h1>Product Pick</h1>
</header>
<main>
<form>
<!-- write your html here-->
<!--
<!-- First name-->
<fieldset>
<label for = "first-name">First Name</label>
<input type="text" id="first-name" name="first-name" required pattern=".*\S.*\S.*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job on the validation. This works well

aria-describedby="fnameHelp">
<small id="fnameHelp">Must be at least 2 characters long</small>
</fieldset>
<!-- Last name-->
<fieldset>
<label for = "last-name">Last Name</label>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are there spaces bet ween the html attirbute and its value?

<input type="text" id="last-name" name="last-name" required pattern=".*\S.*\S.*"
aria-describedby="lnameHelp">
<small id="lnameHelp">Must be at least 2 characters long</small>
</fieldset>
<!-- Email-->
<fieldset>
<label for = "email">Email</label>
<input type="email" id="email" name="email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$"
aria-describedby="emailHelp">
Comment on lines +86 to +87
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I find the code hard to read because of the formatting (long lines). How can you ensure consistent formatting in your code?

<small id="emailHelp">Must be a valid email address</small>
</fieldset>
<!-- Password-->
<fieldset>
<label for = "password">Password</label>
<input type="password" id="password" name="password" required pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
aria-describedby="passwordHelp">
<small id="passwordHelp">Must be at least 8 characters long and include at least one uppercase letter, one lowercase letter, one number, and one special character</small>
</fieldset>
<!--Shirt Color-->
<fieldset>
<legend>Shirt Color</legend>
<label for = "shirt-color">Shirt Color</label>
<select id="shirt-color" name="shirt-color" required>
<option value="">Select a color</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
</fieldset>
<!---Shirt Size-->
<fieldset>
<label for = "shirt-size">Shirt Size</label>
<select id="shirt-size" name="shirt-size" required>
<option value="">Select 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>

<!--Submit button-->
<fieldset>
<button type="submit">Submit Form </button>
</fieldset>

<!--
What is the customer's name? I must collect this data and ensure it contains at least two non-space characters.
What is the customer's email? I must make sure the email is valid. Email addresses follow a consistent pattern.
What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours?
What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL
try writing out the requirements first as comments
this will also help you fill in your PR message later-->
</form>
</main>
<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>By Tobias Amaechina</p>
</footer>
</body>
</html>
Loading