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

JS Form Validation: Clarify intended approach with JS-only validation #27316

Open
3 tasks done
MaoShizhong opened this issue Feb 9, 2024 · 1 comment · May be fixed by #27576
Open
3 tasks done

JS Form Validation: Clarify intended approach with JS-only validation #27316

MaoShizhong opened this issue Feb 9, 2024 · 1 comment · May be fixed by #27576
Assignees
Labels
Status: Stale This issue/PR has been inactive for over 30 days and will be closed if inactivity continues

Comments

@MaoShizhong
Copy link
Contributor

Checks

Describe your suggestion

The JS form validation lesson teaches the constraint validation API.
The assignment in the practice section of that lesson indicates

The form doesn’t need to actually submit, but you should give an error message if the button is pushed with any active errors or unfilled required fields. For the sake of this lesson, make sure all of the validation occurs in the JavaScript file. If all is well and the form is “submitted”, give the user a high five.

I have seen some confusion over exactly what this expects of the learner, with the following two interpretations being the most common:

  1. Set novalidate on the <form> element, then use the appropriate form inputs in the HTML. Validate via the constraint validation API in the JS file.
  2. Use only <input type="text"> i.e. cannot use even stuff like type="number"/type="email" and all validation must be 100% custom in JS. This would mean for something like an email input, instead of using an email input and utilising reportValidity and other features of the constraint validation API, you use a text input and manually parse the input string for whether it conforms to an email pattern, then report the validity on that.

I think the current lesson wording is unclear as to which it expects the learner to do. Personally, I'm inclined to believe it intends the former, where it is fine to use different input types, just novalidate the <form> and use the constraint validation API as taught (so you won't have to manually parse a string to conform to a specific pattern for basic things like number input/email input etc.).

Can this be clarified and whether it is agreed the current wording can be improved to make the intent clearer?

Path

Ruby / Rails, Node / JS

Lesson Url

https://www.theodinproject.com/lessons/node-path-javascript-form-validation-with-javascript#practice

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

@MaoShizhong MaoShizhong self-assigned this Mar 7, 2024
@MaoShizhong MaoShizhong linked a pull request Mar 7, 2024 that will close this issue
7 tasks
Copy link

github-actions bot commented Apr 7, 2024

This issue is stale because it has had no activity for the last 30 days.

@github-actions github-actions bot added the Status: Stale This issue/PR has been inactive for over 30 days and will be closed if inactivity continues label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale This issue/PR has been inactive for over 30 days and will be closed if inactivity continues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant