Limit user-submitted code through JS in client

Source: Internet
Author: User
Tags reference reset client
Program Introduction
1. Method One: Hiddenform hidden form method: View function Hiddenform
2. Method Two: Disbuttons Disable button method: View function Disbuttons disButtons2
3. This procedure for the client JavaScript program limit multiple submissions, glaciers original blue ideal, welcome to reprint, but please retain my information, thank you
4. Source code posted in my mobile phone theme station: Http://www.qumiao.com/javascript/disRepSubmit.rar (I all original procedures are packaged in this)
5. Author Mailbox and qq:binghe6218@163.com 369768917 (please remind when you add Friends: Program Exchange)

function Source:
The following is a reference fragment by alixixi.com:
function Checkform (frm)
{
The following line is a common validation judgment
if (frm.keyword.value== "") {alert (' "Mobile theme name" cannot be empty '); Frm.keyword.focus (); return false}

In this case, the following function can be performed after validation to prevent form data from being repeatedly submitted
Disbuttons (); Function call 1
DisButtons2 (); or function call 2
Hiddenform (frm); or function call 3

}


/*
Function Name: Hiddenform
Function: Make the form automatically hidden when submitting without affecting the submission of the data
*/
The following is a reference fragment by alixixi.com:
function Hiddenform (frm)
{
Waitstr the prompt that appears during the commit process, you can set the
var waitstr = "<center> waiting...</center>";
frm.innerhtml = "<div style= ' Display:none; ' > "+frm.innerhtml+" </div> "+WAITSTR;
}


/*
Function Name: disbuttons
function function: Before committing, disable the button,reset,submit in all forms disabled;
If it is a submit button, add the same hidden text box hidden object so that the submitted information does not slip through
Author: Glacier
*/
The following is a reference fragment by alixixi.com:
function Disbuttons ()
{
for (k=0;k<document.all.length;k++)
{
var obj = document.all (k)
if (obj.type== ' button ' | | | obj.type== ' Submit ' | | | obj.type== ' reset ')
{
Obj.disabled = True
if (obj.type== ' submit ')
{
var onewnode = document.createelement ("input");
Onewnode.type = "hidden"
Onewnode.name = Obj.name
Onewnode.value = Obj.value
Frm.insertadjacentelement ("BeforeEnd", Onewnode);
Obj.insertadjacentelement ("Afterend", Onewnode);
}
}
}
}

/*
Function Name: disButtons2
function function: Before committing, disable the button,reset,submit in all forms disabled;
If it is a submit button, add the same hidden text box hidden object so that the submitted information does not slip through
Author: Glacier
Function Description: Like the function above, but the scope of the browser is wider, it is recommended to use this function.
*/
The following is a reference fragment:
function DisButtons2 ()
{
for (k=0;k<document.forms.length;k++)
{
var frm = document.forms[k]
for (i=0;i<frm.length;i++)
{
var obj = frm.elements[i]
if (obj.type== ' button ' | | | obj.type== ' Submit ' | | | obj.type== ' reset ')
{
Obj.disabled = True
if (obj.type== ' submit ')
{
var onewnode = document.createelement ("input");
Onewnode.type = "hidden"
Onewnode.name = Obj.name
Onewnode.value = Obj.value
Frm.insertadjacentelement ("BeforeEnd", Onewnode);
Obj.insertadjacentelement ("Afterend", Onewnode);
}
}
}
}
}


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.