First, use the flag. The following Code sets the checkSubmitFlg flag:
<Script language = "" javascript "">
Var checkSubmitFlg = false;
Function checkSubmit (){
If (checkSubmitFlg = true) {return false; // After the form has been submitted once, checkSubmitFlg changes to true, and cannot be submitted based on judgment.
}
CheckSubmitFlg = true;
Return true;
}
</Script>
<Form name = "form1" method = "post" onsubmit = "return checkSubmit ();">
........... </Form>
Second, set in the onsubmit event to invalidate the submit button after the first submission. The Code is as follows:
<Form action = "about: blank" method = "post" onsubmit = "getElementById ('submitinput'). disabled = true;
Return true ;"
Target = "_ blank">
<Input type = "submit" id = "submitInput"/>
</Form>
</Body>
</Html>
</Script>
Because the source code of the program conflicts with the WIN2000 registry, invalid pages will appear after the post is sent, so many non-malicious duplicate posts in the Forum will come up with a solution, avoid repeated submission with JS. The following are some source code:
<Script Language = 'javascript '>
Function formsubmit (){
Today = new Date ();
Var NowHour = Today. getHours ();
Var NowMinute = Today. getMinutes ();
Var NowSecond = Today. getSeconds ();
Var mysec = (NowHour * 3600) + (NowMinute * 60) + NowSecond;
If (mysec-document.formsubmitf.mypretime.value)> 600)
// 600 is only a time value, that is, repeated submission is prohibited within 5 minutes. The value is set as happy as you are.
{
Document. formsubmitf. mypretime. value = mysec;
}
Else
{
Alert ('one click is enough. Please do not submit it again! Please be patient! Thank you for your cooperation! ');
Return false;
}
Document. forms. formsubmitf. submit ();
}
</Script>
</HEAD>
<Body bgcolor = "# FFFFFF">
<Form name = formsubmitf id = "the" method = "post" action = "XXX. asp">
<Input type = hidden name = 'mypretime' value = '0'> // This sentence cannot be small. An initial time value is passed with an implicit variable.
// Here is the content you want to submit
<Input type = "button" value = "written" name = "button1" class = "4 round" onclick = 'formsubmit () '> & nbsp; <font class = "red"> (please wait !) </Font> & nbsp; <input type = "reset" value = "re-write" name = "button2" class = "4 round">
</Form>
With this code, repeated posts on the Forum are obviously reduced, but there is a drawback: refresh once and detection does not work. The advantage is that JS detection does not require additional permission support, as for how it works, you can use it without having to use it. (It is best to add detection to both the frontend and backend)