Search In This Blog

2020-10-30

Standard Save button prevent double click

Html source:
<form accept-charset="UTF-8" action="/a02/e" enctype="application/x-www-form-urlencoded" id="editPage" method="post" name="editPage" onsubmit="if (window.ffInAlert) { return false; }if (window.sfdcPage && window.sfdcPage.disableSaveButtons) { return window.sfdcPage.disableSaveButtons(); }" >

In main.js, two function named:
EditPage.prototype.disableSaveButtons ⇒ may used to disable save button after click
EditPage.prototype.enableSaveButtons ⇒ may used to active save button if error happened

Looks like salesforce is use form to submit data, and js to prevent doubleclick.

Prevent double submission of forms |二重送信防止

<!-- 送信ボタン2度押し防止策 -->
<script type="text/javascript">
var isSave = false;
function check(){
if (!isSave) {
isSave = true;
return true;
}
return false;
}

<apex:commandButton action="{!test}" value="Refresh" onclick="return check();"/>

https://developer.salesforce.com/forums?id=906F000000095yxIAA
http://salesforce.stackexchange.com/questions/7729/disable-commandbutton-after-first-click-to-prevent-double-submission