Restrict repeated submission of forms on the JSP client

Source: Internet
Author: User

Restrict repeated submission of forms on the JSP client
There are two ways to restrict the repeated submission of forms on the client:
First, set a flag variable in a Javascript script to identify whether the form has been submitted. If yes, a dialog box is displayed, indicating "submit again ".
Type 2: After you click the submit button, set the submit button to the disabled status. In this way, you cannot submit the button again, and the client cannot submit the button again.
Use the first method: 1. Create a clienttest1.jsp file. The Code is as follows:

<% @ Page Language = "Java" C
Pageencoding = "gb2312" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" C>
<Title> restrict repeated submission on the client </title>
<Script language = "JavaScript"
<! -- Define repeated submission flag variables -->
VaR repeatsubmitflag = false;
<! -- Repeated submission check function -->
Function checksubmit ()
{
If (repeatsubmitflag) <! -- If the flag is true, the page has been submitted. -->
{
Window. Alert ('repeated submission is prohibited! ');
Return false;
}
Else
{
Repeatsubmitflag = true;
Return true;
}
}
</SCRIPT>
</Head>
<Body bcolor = "# ffffff">
<Form name = "form_client" Action = "http://www.dlmu.edu.cn">
<Input type = "checkbox" name = "check_1" Checked = true/> Dalian Maritime University
<Input type = "Submit" name = "submitok"/>
</Form>
</Body>
</Html>

2. If the form is submitted repeatedly, an error prompt dialog box will pop up.

The second method is used:
1. Create a clienttest2.jsp file. The Code is as follows:
<% @ Page Language = "Java" C
Pageencoding = "gb2312" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" C>
<Title> repeated submission of client restrictions-2 </title>
</Head>
<Body bgcolor = "# ffffff">
<Form name = "form_client" Action = "http://www.dlmu.edu.cn"
>
<Input type = "checkbox" name = "check_1" Checked = "true"/> Dalian Maritime University
<Input type = "Submit" name = "submitok"/>
</Form>
</Body>
</Html>

2. If the form is submitted repeatedly, an error prompt dialog box will pop up.

This post from zdnetchina Chinese community http://bbs.zdnet.com.cn, this post address: http://bbs.zdnet.com.cn/viewthread.php? Tid = 93542

 

 

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.