-
Notifications
You must be signed in to change notification settings - Fork 3.9k
update title and improvements - Forms: submit section #3367
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
c26cf0e
f204058
ec3c6e7
79fed03
16a152b
5088baf
6490077
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Forms: event and method submit | ||
# Forms: submit event and method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe: # Forms: `submit` event and method |
||
|
||
The `submit` event triggers when the form is submitted, it is usually used to validate the form before sending it to the server or to abort the submission and process it in JavaScript. | ||
The `submit` event triggers when the form is submitted. It is usually used to validate the form before sending it to the server or to abort the submission and process it in JavaScript. | ||
|
||
The method `form.submit()` allows to initiate form sending from JavaScript. We can use it to dynamically create and send our own forms to server. | ||
|
||
|
@@ -10,7 +10,7 @@ Let's see more details of them. | |
|
||
There are two main ways to submit a form: | ||
|
||
1. The first -- to click `<input type="submit">` or `<input type="image">`. | ||
1. The first -- to click `<input type="submit">`, `<input type="image">` or `<button>`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe:
Should probably include the warning to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shallow-beach regarding the warning to use type='button': the article focuses exclusively on submit events which do refresh the document, but can be prevented using preventDefault() - mentioned in the below lines.. So please do review again if the warning should be included in this article There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think your reasoning is good, thanks! |
||
2. The second -- press `key:Enter` on an input field. | ||
|
||
Both actions lead to `submit` event on the form. The handler can check the data, and if there are errors, show them and call `event.preventDefault()`, then the form won't be sent to the server. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect. modal is an official term