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

Write new basic forms article for learn #37776

Merged
merged 14 commits into from
Jan 27, 2025

Conversation

chrisdavidmills
Copy link
Contributor

Description

This PR updates the Learn web development Forms and buttons in HTML article, which is currently incomplete.

A couple of notes:

  • There are a couple of links to externally hosted examples, which currently 404. I was intending to put them somewhere like the learning-area repo, but I've not put them in place yet as I wanted to get the code reviewed first.
  • There is a lot of forms content not covered here, but I wanted to try to create a single article that covered enough of the basics to give the reader just enough for now. Let me know if you think there is anything critical missing.
  • Also let me know if you feel like anything is superfluous or waffly. I want to make it shorter if possible ;-)

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner January 23, 2025 19:01
@chrisdavidmills chrisdavidmills requested review from hamishwillee and bsmth and removed request for a team January 23, 2025 19:01
@github-actions github-actions bot added the size/m [PR only] 51-500 LoC changed label Jan 23, 2025
Copy link
Contributor

github-actions bot commented Jan 23, 2025

Preview URLs

External URLs (1)

URL: /en-US/docs/Learn_web_development/Core/Structuring_content/HTML_forms
Title: Forms and buttons in HTML

(comment last updated: 2025-01-27 16:55:07)

@chrisdavidmills chrisdavidmills requested a review from bsmth January 27, 2025 14:18
Form validation is a huge topic that is beyond scope for this article, so we will leave it here for now. For now, bear in mind that there are two types of form validation:

- Client-side validation, which happens in the browser, implemented using a combination of form validation attributes (like `required`) and JavaScript. Client-side validation is useful for giving users instant hints when they entered the wrong data, but is no so effective at stopping malicious data from getting through. It is too easy to turn off JavaScript or alter client-side code so that the validation no longer works.
- Server-side validation, which happens on the server, implemented using whatever language the server is using. Server-side validation is great for stopping malicious code, as it can't be tampered with easily. It is not so good at giving users hints about incorrect data as the data has to go to the server, get validated, and then the result sent back to the client before the user can be notified.
Copy link
Member

Choose a reason for hiding this comment

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

bit wordy, but I wanted to note that it can happen accidentally or on purpose that your sever receives weirdly-formatted messages, and the motivation doesn't matter, you shouldn't trust client data (will be in a proper format):

Suggested change
- Server-side validation, which happens on the server, implemented using whatever language the server is using. Server-side validation is great for stopping malicious code, as it can't be tampered with easily. It is not so good at giving users hints about incorrect data as the data has to go to the server, get validated, and then the result sent back to the client before the user can be notified.
- Server-side validation, which happens on the server in whatever language the server is running. Badly-formed messages can be sent to a server by accident or on purpose. The conventional wisdom is to make sure that your server doesn't trust anything a client is sending to avoid bugs or security issues caused by malformed messages. Server-side validation is great for stopping malicious messages, as it's harder to tamper with the code running on the server. Server-side validation is not so good at giving users hints about incorrect data because the data has to go to the server, get validated, and then the result is sent back to the client before the user can be notified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you've got a good point here. I used your text but tweaked it a bit.

Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

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

Thanks, Chris - couple of suggestions, but leaving a +1 for when you've had a look!

@chrisdavidmills chrisdavidmills merged commit b23adcb into mdn:main Jan 27, 2025
8 checks passed
@chrisdavidmills chrisdavidmills deleted the new-forms-article-for-learn branch January 27, 2025 16:55
@chrisdavidmills
Copy link
Contributor Author

We are merged. Cheers for the great review, @bsmth!

@bsmth
Copy link
Member

bsmth commented Jan 27, 2025

Thanks a lot 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants