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
94 changes: 88 additions & 6 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,104 @@
<title>My form exercise</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}

form {
max-width: 400px;
}

label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}

input[type="text"],
input[type="email"],
select {
width: 100%;
padding: 8px;
margin-bottom: 15px;
box-sizing: border-box;
}

fieldset {
margin-bottom: 15px;
}

button {
padding: 10px 20px;
}
</style>
</head>


<body>
<header>
<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-->
<!-- Collect the customer's name. Name contain at least 2 non-space characters. -->
<label for="name">Customer Name:</label>
<input
type="text"
id="name"
name="name"
pattern=".*\S.*\S.*"
title="Name must contain at least 2 non-space characters."
required
/>
Comment on lines +55 to +62

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.

  • When the user input is rejected, the browser shows "Please match the requested format" but it is not clear what the requested format is. Can you make it clearer to the user what format should a name be?

  • Should a name such as "C J" (with a space between two alphabets) be considered a name containing at least two non-space characters?


<!-- Collect the customer's email address. Email must be in a valid email format. -->
<label for="email">Email Address:</label>
<input
type="email"
id="email"
name="email"
required
/>

<!-- Allow the customer to choose a T-shirt colour. Only provide three colour options. -->
<fieldset>
<legend>Choose a Colour</legend>

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

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.

Note: Here's is an alternate markup that does not involve "id" and "for" attributes.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, understood. The input is inside the label attribute, making it easier to read and needing less code.


<input type="radio" id="blue" name="colour" value="blue">
<label for="blue">Blue</label>

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

<!-- Allow the customer to choose a T-shirt size. Provide sizes: XS, S, M, L, XL, XXL -->

<label for="size">T-shirt Size:</label>
<select id="size" name="size" required>
<option value="">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>

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

</form>
</main>

<footer>
<!-- change to your name-->
<p>By HOMEWORK SOLUTION</p>
<p>By Khaliun Baatarkhuu</p>
</footer>
</body>
</html>
Loading