JavaScript - prevent multiple form submittals |
| Printer Friendly Version |
|
|
| Often times we need to prevent a user from submitting the same form twice. This issue becomes especially important with slow connections. Here is a small JavaScript sample of how to prevent duplicate form submittals: |
|
Often times we need to prevent a user from submitting the same form twice. This issue becomes especially important with slow connections. Here is a small JavaScript sample of how to prevent duplicate form submittals: <SCRIPT language=JavaScript > var submitcount=0; function checkSubmit() { if (submitcount == 0) { submitcount++; return true; } else { alert('This form has already been submitted.' ); return false; } } </SCRIPT> <form name=frmSubmit method=post onSubmit=" return checkSubmit();" action="mypage.asp" > |
|
| Submission Date: 9/23/2005 3:03:18 PM |
| Submitted By: Robbe Morris |
| My Home Page: http://www.robbemorris.com |
|
| My Biography |
| Robbe has been a Microsoft MVP for C# since 2004. He is also the co-founder of EggHeadCafe. Robbe has extensive experience with web technologies, .NET, C#, CTI based applications, system administration, .NET Compact Framework, and data modeling. In his spare time, he blogs from time to time at http://robbemorris.blogspot.com |