0
Why does the submit input clear my screen?
I'm making a form, but I don't want it to disappear after I hit submit. How do I fix this?
4 Answers
+ 6
When we place a <button> in a <form>, it is recommended to explicitly specify the 'type' attribute for the <button>
https://html.com/attributes/button-type/
One of the reason was to prevent the <button> to be mistakenly understood as the button for submitting the <form>, while it may not be the actual intention.
In case of 'submit' event interception, best answer in below stackoverflow page provides a decent example IMO
https://stackoverflow.com/questions/3350247/how-to-prevent-form-from-being-submitted
+ 4
Do you have a link to the codebit where this is happening?
+ 4
Yes, I do here you go.
https://www.sololearn.com/compiler-playground/WwnCB18OQ8GE
+ 1
they does not disappear..the submit button basically tries to perform the action of form submission theirby refreshing the link