Tuesday 23 April 2013

Disable submit button to prevent double form submission

Sometimes dealing with forms with Submit button can cause duplicate processing issues which results duplicate database records, multiple email id's etc. To prevent this javascript provides an easy way to disable multiple submission of form once the form has been submitted. Its also helpful for reservation/booking management systems such as hotel management system to prevent multiple or unintentional bookings.


Here is the simple javascript code will do the job


<form action="javascript:void(0);" name="myform">
   <input type="text" name="formContents" value="Example">
   <input type="Submit" value="Submit" name="submitbtn" onClick="myform.submitbtn.disabled=true;">
</form>

Linking: form_name . submit_button_name . disabled=true
i.e. myform . submitbtn . disabled=true;


Demo

No comments:

Post a Comment