An example of JavaScript to prevent repeated submission of forms, javascript forms

Source: Internet
Author: User

An example of JavaScript to prevent repeated submission of forms, javascript forms

<! DOCTYPE html> 

How to use javascript to prevent repeated submission of forms

<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>
 
Why does the javascript I wrote in html not prevent repeated submission of forms?

If you want to disable the re-submission when the submission form is in progress, you can disable the button in dosubmit. We recommend that you use jquery. cookie to determine if you want users to submit the application again after the submission (which is restricted by HTML pages at the same time.

If your code does not show your expectation, you can try placing dosubmit () on The onclick page of the submit button, and add form in dosubmit. submit ().

Related Article

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.