Avoid repeated submission of forms (JS)

Source: Internet
Author: User
Before their own forum because the program source code with the WIN2000 registry conflict, Post issued will appear invalid page, so that the forum has a lot of malicious repeated posts, and then came up with a way to avoid duplication with JS submission, the following is part of the 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, 5 minutes to prohibit repeated submissions, the value of your happy set
{
Document.formsubmitf.mypretime.value=mysec;
}
Else
{
Alert (' Press once is enough, do not repeat! Please wait patiently! 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 reduced by passing an initial time value with an implied variable

Here's what you want to submit.

<input type= "button" value= "written" Name= "Button1" class= "4round" > <font class= "Red" > (Please press once and wait patiently!) ) </font> <input type= "reset" value= "rewrite" name= "Button2" class= "4round" >
</form>

With this code, the Forum's repeated posts are significantly reduced, but there is a drawback, is to refresh once, the detection will not work, the advantage is to use JS detection, do not need additional permissions to support, as to the effect of the use of the need for you, (preferably the front end with the back end are added

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.