London | 26-ITP-SEP | Sakiya Mayow | Sprint 1 | Form Controls - #1500
zakiaao-tech wants to merge 12 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
You have few things that need attention. Things to sort before it can be marked Complete:
- Name validation. The task asks for one name field that must contain at least two non-space characters, using the regex the README gives you. At the moment two spaces get through. See line 20.
- Forms shouldn't have multiple submit buttons. Only a single submit button. The idea is that once the form is filled in, the submit button is clicked. You have four at the moment, one for each field. See line 23.
- The validator reports 7 errors: a legend outside a fieldset, ids and names with spaces in them, a missing space between attributes on line 28, and the regex sitting on its own as an attribute. Run the file through https://validator.w3.org/ and work through them.
- Formatting. Prettier fails on this file and the indentation drifts further right as it goes. Run
npx prettier --write Form-Controlsfrom the repo root. - The footer still says HOMEWORK SOLUTION, line 76.
You asked two things in the description.
No JavaScript is needed, the task is HTML and CSS only.
To run Lighthouse yourself in Chrome: open the page that contains your form, right click and choose Inspect, click the Lighthouse tab at the top of DevTools (if you can't see it, click the >> arrows), tick Accessibility, then click Analyze page load. The score and any failing checks appear in the panel. Also, every PR here gets a deploy preview and Lighthouse runs on it automatically. Scroll up to the netlify bot comment on this PR and you'll see your scores there, including Accessibility 100.
One thing for next time: this PR is opened from your main branch. Make a branch for each task (feature/form-controls) and open the PR from that, so main stays clean.
Add the Needs Review label again once you've pushed.
| <div> | ||
| <legend>Customer details</legend> | ||
| <label for="firstname">First name:</label> | ||
| <input type="text" id="firstname" name="firstname" required .*\S.*\S.*> <br> |
There was a problem hiding this comment.
The regex from the README is sitting here as an attribute on its own, so the browser ignores it. Which attribute is it meant to be the value of? I typed two spaces into this field on the deploy preview and it passed. Also the task asks for one name field, not first and last.
There was a problem hiding this comment.
One name field now, good. The regex is still a bare attribute though, so this one is still open. See the new comment on line 23.
There was a problem hiding this comment.
Fixed now, and two spaces are rejected. Good.
| <input type="text" id="firstname" name="firstname" required .*\S.*\S.*> <br> | ||
| <label for="lastname">Last name:</label> | ||
| <input type="text" id="lastname" name="lastname" required> | ||
| <button type="Submit">Submit</button> |
There was a problem hiding this comment.
There are four Submit buttons in this form, and one of them is inside the <select>. A form needs one. Where should it go?
| <form> | ||
| <!-- write your html here--> | ||
| <div> | ||
| <legend>Customer details</legend> |
There was a problem hiding this comment.
<legend> is only valid inside one particular element, and it isn't <div>. Which element groups a set of fields and takes a legend? The MDN page from the prep on structuring a form shows it.
|
|
||
| <div> | ||
| <label for="T-shirt colour">Select one T-shirt colour:</label> | ||
| <select name="T-shirt colour" id="T-shirt colour" required> |
There was a problem hiding this comment.
An id can't contain spaces, and a name shouldn't either. Try submitting the form and look at what appears in the address bar for this field.
There was a problem hiding this comment.
Ids and names fixed. The for on the labels wasn't updated to match, so they've come apart. See the comment on line 34.
There was a problem hiding this comment.
Matching now. Good.
|
|
||
| <div> | ||
| <label for="email"> Email:</label> | ||
| <input type="email"name="email" id="email" required> |
There was a problem hiding this comment.
Missing space between type="email" and name="email". The formatter will fix this one.
There was a problem hiding this comment.
I received all your feedback and I have completed the corrections, and I will definitely create branch next time. Thank you !
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Good progress: one name field, one submit button, ids without spaces, the footer, and the file is formatted. Two things still outstanding:
- The regex is still sitting on its own on line 23, so the browser ignores it and two spaces still pass as a name. It needs to be the value of an attribute. The README tip says which one.
- When you removed the spaces from the ids on lines 35 and 45 the
foron the labels above them (lines 34 and 44) kept the old spelling, so the labels no longer point at anything and the two dropdowns have lost their labels. The HTML validator (https://validator.w3.org/) reports both.
Add the Needs Review label again once you've pushed and I'll mark it Complete.
| id="fullname" | ||
| name="Fullname" | ||
| required | ||
| .*\S.*\S.* |
There was a problem hiding this comment.
Still on its own here. Look at how required on the line above is written, and how type="text" is written. The regex needs to be written the same way, as the value of the attribute the README tip names.
| </div> | ||
|
|
||
| <div> | ||
| <label for="T-shirt colour">Select one T-shirt colour:</label> |
There was a problem hiding this comment.
for="T-shirt colour" but the select below is now id="T-shirt-colour". They have to match exactly. Same on line 44.
|
Thank you Abdi for pointing it out, I have learned from my mistakes, and I think I got it this time if not please let me know. |
There was a problem hiding this comment.
You've got it. The regex is in the pattern attribute and does its job, the labels point at their dropdowns again, and the validator is clean. Marking this Complete.
Two small things for next time, not needed here. Prettier flags the file again: the /> endings it wrote earlier have gone. If that wasn't you, VS Code may have a second formatter running that undoes Prettier's work. Check that Prettier is the default formatter and that format on save uses it, as in https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md, then run it once more. And in the README checklist, [x ] with a space inside the brackets doesn't render as ticked, it needs to be [x].
|
All done! |

Learners, PR Template
Self checklist
Task code
CYF-1004
Changelist
I have added the required name and email fields with validation.
I added 3 colour options.
I added 6 T-shirt sizes: XS, S, M, L, XL, XXL.
Questions
I did not use Javascript, will it be okay or do I have to redo it?
Also I am unsure if the lighthouse inspection worked or not.