Is it okay to tag the form without sending anything to the server?

Asked 1 years ago, Updated 1 years ago, 31 views

I have a question about HTML form tags.
I think it is normal to use the form tag for the purpose of sending the information entered by the user to the server, but if I do not send the input data to the server, is it not acceptable to enclose it with the form tag?For example, if you press the OK button, the program will be completed at the front end by simply processing the input data with JavaScript and displaying it on the screen.

javascript html

2022-09-30 16:56

2 Answers


From the W3c Documentation https://www.w3.org/TR/html5/forms.html#introduction-1
Or
https://www.w3.org/TR/html51/sec-forms.html#forms-introduction

No client-side scripting is needed in many cases, through an API is available so that scripts can be authenticated the user experience or use forms for purpos other than submitting data to a server.

In most cases, it is not necessary, but the form is made available for other purposes besides sending it to the server (free translation).

In other words, if you want to use the form without sending it to the server,
"I don't recommend it positively, but I think it's okay to use it."


2022-09-30 16:56

If you return false; in the onsubmit event, you can stop sending.

For example, simply
onsubmit="return false" should be added to the form tag as follows:

<form id="form_id" method="action="onsubmit="return false">
various forms
</form>

Even if you use a button that makes you submit,
You can return false; in the onsubmit event handler function.


2022-09-30 16:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.