DocumentStruts2 provides a repeat commit check mechanism, but what I want is not to bring up an error page, but to execute only one commit as nothing happens.
1. Set a variable and a variable, which can only be submitted once.
Reference content is as follows:
<Script type = "text/javascript">
Function checkSubmit (){
If (checkSubmitFlg = true ){
Return false;
}
CheckSubmitFlg = true;
Return true;
}
</Script>
<Form onsubmit = "return checkSubmit ();" method = "post"> |
Method 1 is effective in both IE6 and FIREFOX experiments.
2. How to disable the button
Because our server is too slow, the buttons are grayed out to provide a better user experience.
Reference content is as follows:
<Script type = "text/javascript">
Function disableSubmit (form ){
Var elements = form. elements;
For (var I = 0; I <elements. length; I ++ ){
If (elements [I]. type = 'submit '){
Elements [I]. disabled = true;
}
}
}
</Script>
<Form name = "form1" onsubmit = "setTimeout ('disablesubmit (form1) ', 100) return checkSubmit ();" method = "post"> |
If it is immediately disabled, the separate action settings of the button will become invalid. Therefore, a delay is required.
Method 2 is valid in IE6. The error message is invalid in FIREFOX because the cause is unknown. But it is the second insurance. It doesn't matter.