Prevents the form,link from being submitted more then once

เวลา double click ที่ link, form ทำให้มันทำงานซ้ำซ้อนหลายครั้งอีกทั้ง javascript ยังทำงานแบบ asynchronous method ทำให้ค่าผิดพลาดได้ จึงต้องเขียนป้องกันการ double click ดังตัวอย่าง

<script type="text/javascript">

var requestSubmitted = false;
       function submitRequest() {
              if (!requestSubmitted ) {
                     requestSubmitted  = true;
                     return true;
              return false;

<form action="Logon" method="POST" onsubmit="javascript:submitRequest()">



About WK

Kajook is a Senior Software Engineer. Job is Design & Develop in Java EE environment on Glassfish. I'm Interested in Agile software development ,iOS and Android.
This entry was posted in ploblem and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s