Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITP London Jan 2025| Samunta Sunuwar |Module Onboarding | Form Controls|WEEK 2 #218

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
23 changes: 11 additions & 12 deletions Form-Controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

<!--{{<objectives>}}>-->

- [ ] Interpret requirements and check against a list of criteria
- [ ] Write a valid form
- [ ] Test with Devtools
- [ ] Refactor using Devtools
- [x] Interpret requirements and check against a list of criteria
- [x] Write a valid form
- [x] Test with Devtools
- [x] Refactor using Devtools
<!--{{<objectives>}}>-->

## Task
Expand All @@ -30,18 +30,17 @@ Do not write a form action for this project.

Let's write out our testable criteria. Check each one off as you complete it.

- [ ] I have used HTML only.
- [x] I have used HTML only.
- [x] I have not used any CSS or JavaScript.

### 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.
- [x] All inputs have associated labels.
- [x] My Lighthouse Accessibility score is 100.
- [x] I require a valid name. I have defined a valid name as a text string of two characters or more.
- [x] I require a valid email.
- [x] I require one colour from a defined set of 3 colours.
- [x] I require one size from a defined set of 6 sizes.

## Resources

Expand Down
60 changes: 54 additions & 6 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,64 @@
<h1>Product Pick</h1>
</header>
<main>
<p>
<strong>Required fields are followed by</strong>
<strong><span aria-label="required">*</span></strong>.
</p>
<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>
<!-- 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 -->
<section id="customer">
<fieldset>
<legend>Customer Details</legend>
<p>
<label for="name">Name:<strong><a aria-label="required">*</a></strong>
<input type="text" id="name" name="name" placeholder="Full Name" minlength="3" required>

Choose a reason for hiding this comment

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

You need to require at least 2 characters for the name field.
You also need to inform the user that their input is incorrect.

Copy link
Author

Choose a reason for hiding this comment

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

@Waldo-Strydom Hi, thank you for the feedback. I have set the minlength to 2.
Please could you elaborate your second feedback "You also need to inform the user that their input is incorrect." I believe I have used correct validation for the form type="text" for Name and type="email" for email address. I am not sure how I can inform user their input is incorrect apart from using validation with HTML. Can you please point me in the direction of how I can achieve this.

Choose a reason for hiding this comment

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

image

As an example it should look like this.

You can give each field a title, to communicate with users.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your advice, I have added the title attribute now. Please could you review.

</p>
<p>
<label for="email">Email:<strong><a aria-label="required">*</a></strong>
<input type="email" id="email" name="email" placeholder="Email Address" required>

Choose a reason for hiding this comment

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

You also need to inform the user that their input is incorrect.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your advice, I have added the title attribute now. Please could you review.

</p>
</fieldset>
</section>
<section id="order">
<fieldset>
<legend>Order Details</legend>
<p>
<label for="color">Please pick a color for the T-shirt:</label>
<select id="color" name="color">
<option value="Black">Black</option>
<option value="Gray">Gray</option>
<option value="White">White</option>
</select>
</p>
<p>
<label for="size">Please pick a size for the T-shirt:</label>
<select id="size" name="size">
<option value="XS">Extra Small</option>
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
<option value="XL">Extra Large</option>
<option value="XXL">2XL</option>
</select>
</p>
<p>
<label for="number">Please input quantity you would like to order:<strong><a aria-label="required">*</a></strong></label>

Choose a reason for hiding this comment

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

Quantity is not on the brief. Please remove it.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Waldo, thank you for your feedback, I have removed this

<input type="number" id="number" name="number" min="1" max="10" required>
</p>
</fieldset>
</section>
</form>
<section id="buttons">
<button>Submit</button>
</section>
</main>
<footer>
<!-- change to your name-->
<h2>By HOMEWORK SOLUTION</h2>
<h2>By Samunta Sunuwar - Jan 2025 Cohort</h2>
</footer>
</body>
</html>