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
137 changes: 112 additions & 25 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,114 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>My form exercise</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</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-->
</form>
</main>
<footer>
<!-- change to your name-->
<h2>By HOMEWORK SOLUTION</h2>
</footer>
</body>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="description"
content="Accessible t-shirt order form with colour and size selection."
/>
<title>My form exercise</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<header>
<h1>T-shirt Picker</h1>
<p>Please complete all required (*) fields to complete order</p>
</header>
<main>
<form>
<fieldset>
<legend>Customer Info</legend>
<!-- name input, must be min 2 chars long -->
<p>
<label for="name"> Name *</label>
<input
type="text"
id="name"
name="customerName"
placeholder="Jane Smith"
minlength="2"
required
/>
</p>
<!-- email input, must be a valid email format -->
<p>
<label for="email"> Email *</label>
<input
type="email"
id="email"
name="customerEmail"
placeholder="jsmith@email.com"
pattern="^[\w.-]+@[\a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
Copy link

Choose a reason for hiding this comment

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

\a is invalid inside character class
Browsers already validate emails using: type="email"

you can remove the pattern completely
<input type="email" ... required />

Copy link
Author

Choose a reason for hiding this comment

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

Ops, that was a missed typo. I've corrected it now, thank you

Copy link
Author

Choose a reason for hiding this comment

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

When you say remove the pattern do you mean for this specific sprint or in general?

required
/>
</p>
</fieldset>
<fieldset>
<legend>Colours</legend>
<!-- colours input, limit to 3 colours only -->
<p>Please select a colour *</p>
Copy link

Choose a reason for hiding this comment

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

We can make this, <legend>Please select a colour *</legend>

Screen readers announce legends, not surrounding text.

Copy link
Author

Choose a reason for hiding this comment

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

I will do that, thank you. I just have a question: does it mean that radio buttons should always be inside a fieldset? Because I don't think I can create a "group" label, only one for each input. Unless there's another trick I could not find.

<ul>
<li>
<p>
<input
type="radio"
name="colours"
id="red"
value="red"
required
/>
<label for="red"> &#x1F7E5; Red </label>
</p>
</li>
<li>
<p>
<input
type="radio"
name="colours"
id="blue"
value="blue"
/>
<label for="blue">&#x1F7E6; Blue </label>
</p>
</li>
<li>
<p>
<input
type="radio"
name="colours"
id="yellow"
value="yellow"
/>
<label for="yellow">&#x1F7E8; Yellow </label>
</p>
Copy link

Choose a reason for hiding this comment

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

The <p> is not needed.

pattern like below is not needed,

<li>
  <p>
    <input>
    <label>
  </p>
</li>

we can have cleaner,

<li>
  <input>
  <label>
</li>

this goes to some places on top as well

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely agree. I wouldn't normally add a

inside a list item, but Lighthouse was not happy with the list's tiny spacing, and, because I could not use CSS, I tried to improvise.
So now I'm not sure if I can remove them or leave forever.

</li>
</ul>
</fieldset>
<fieldset>
<legend>Size</legend>
<p>
<!-- size input, limit to 6 sizes: XS, S, M, L, XL, XXL -->
<label for="size">Please select a size *</label>
<select name="size" id="size" required>
<option value="" disabled selected>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>
</p>
</fieldset>

<!-- submit button -->
<p><button type="submit">Confirm your order</button></p>
</form>
</main>
<footer>
<!-- change to your name-->
<h2>Kris Oldrini | CYF: Intro to Programming</h2>
</footer>
</body>
</html>
Loading