Hi Guys,
In this blog, I'm going to explain about why we should prevent users to submit HTML form multiple time simultaneously and how to do it.
Sometimes if the response is slow, the user can click on the submit button several times. While submitting a form, on the backend server, we create entries in our databases. But when a user submits an HTML form multiple times simultaneously then it is likely to create problem in the database because we save the data and the relationships for the submitted data by the user. So there can be multiple solution for this problem. One is, we can handle multiple form submit at beckend server and other one is we can disable the form submit button if the form is already submitted.
Below is a simple code which prevent user to submit form multiple times simultaneously:
function validateApplicant(form) { $("saveButtonDiv").style.display="none"; $("processDiv").style.display=""; }
In the above example we are disabling the submit button of form when it submits by the user.
All form validation must be done on the server side. This includes multiple submission checks. Never trust the client! This is not just a case if javascript is disabled. Keep in mind that all client codes can be modified. It is somewhat difficult to imagine, but the html / javascript that is spoken with your server is not necessarily the html / javascript you have written.
Hope it helps!
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Shakil Pathan
Shakil is an experienced Groovy and Grails developer . He has also worked extensively on developing STB applications using NetGem .