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
64 changes: 62 additions & 2 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,82 @@
<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>
<h1>Product T-shirts</h1>
</header>
<main>
<form>
<!-- write your html here-->

<!-- 1. What is the customer's name? I must collect this data and ensure it contains at least two non-space characters. -->

<label for="username">Name</label>
<input type="text" id="username" minlength="2" required autocomplete="name">
Comment on lines +22 to +23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you update this input element so that it can reject name containing only space characters? For example, " " (a string made up of two space characters)?

Note:
Your branch is one commit behind the upstream repo (CYF's main). If you use the "Sync fork" feature on your repo on GitHub to update your branch, you will find in the README.md of this exercise a regular expression that can be used to enforce "name 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. -->

<label for="email">Email</label>
<input type="email" id="email" required autocomplete="email">

<!-- 3. What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours? -->

<fieldset>
<legend>Choose a colour</legend>

<label for="red">Red</label>
<input type="radio" id="red" name="colour" value="red" required>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could consider enclosing <input> within <label> as:

            <label>Red
              <input type="radio" name="colour" value="red" required>
            </label>

This way, you don't have to introduce id to every radio button.


<label for="green">Green</label>
<input type="radio" id="green" name="colour" value="green">

<label for="white">White</label>
<input type="radio" id="white" name="colour" value="white">


</fieldset>

<!-- 4. What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL -->

<fieldset>
<legend>Choose a size</legend>

<label for="xs">XS</label>
<input type="radio" id="xs" name="size" value="xs" required>

<label for="s">S</label>
<input type="radio" id="s" name="size" value="s" required>

<label for="m">M</label>
<input type="radio" id="m" name="size" value="m" required>

<label for="l">L</label>
<input type="radio" id="l" name="size" value="l" required>

<label for="xl">XL</label>
<input type="radio" id="xl" name="size" value="xl" required>

<label for="xxl">XXL</label>
<input type="radio" id="xxl" name="size" value="xxl" required>


</fieldset>

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



<!--
try writing out the requirements first as comments
this will also help you fill in your PR message later-->
Comment on lines 77 to 79
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feel free to delete any unnecessary code to keep your code base clean.

</form>
</main>
<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>Made with love by Abid Akhtar</p>
</footer>
</body>
</html>
75 changes: 75 additions & 0 deletions Form-Controls/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: beige;
}

header,
footer {
text-align: center;
margin-bottom: 20px;
}

h1 {
margin-bottom: 10px;
}

main {
display: flex;
justify-content: center;
}

form {
background-color: white;
padding: 20px;
border-radius: 8px;
width: 100%;
max-width: 450px;

display: flex;
flex-direction: column;
gap: 16px;
}

label {
font-weight: bold;
}

input[type="text"],
input[type="email"] {
width: 100%;
padding: 10px;
font-size: 16px;
box-sizing: border-box;
}

fieldset {
border: 1px solid #ccc;
padding: 16px;
}

legend {
font-weight: bold;
padding: 0 6px;
}

fieldset label {
font-weight: normal;
margin-right: 6px;
}

fieldset input[type="radio"] {
margin-right: 16px;
margin-bottom: 10px;
}

button {
padding: 12px;
font-size: 16px;
cursor: pointer;
}

footer p {
font-size: 14px;
}
Loading