Skip to content

Files

Latest commit

284d872 · Nov 9, 2024

History

History

Form-Controls

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 9, 2024
May 14, 2024
May 14, 2024

HTML/ CSS

Forms, styling forms, and Devtools

Aims

  • Interpret requirements
  • Write a valid form
  • Style form controls
  • Test with Devtools
  • Refactor using Devtools

Task

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 then pick a delivery date.

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?
  4. What size does the customer want? I must give the following 6 options: XS, S, M, L, XL, XXL
  5. When do they want the t-shirt to be delivered? I must collect a date and make sure that date is in the next four weeks. How will I do this? How will I make sure there are no mistakes about the date? [Note: with what you've learned, you should be able to do this for "the next four weeks from when you made the page", not for "the next four weeks from when the user visits the page". For now just solve the first problem - you'll learn about how to solve the second problem later in the course]

All fields are required. Do not write a form action for this project.

Developers must test their work.

Let's write out our testable criteria:

  • I have used HTML and CSS only.

HTML

  • My form is semantic html.
  • All inputs have associated labels.
  • 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 size from a defined set of 6 sizes.
  • I require one date from a constrained date range.

CSS

  • I show which element is focused.
  • My Lighthouse Accessibility score is 100.

Extension Task

If you have done all these things and you would like a really big challenge, run a further test and refactor your code.

Sanity check: this extension is tough! Try it in your own time and don't let it hold up your coursework submission.