button to prevent duplicate submissions (click Submit after the Submit button dimmed, after the operation has been completed recovery)

Source: Internet
Author: User

Form form in JSP:

<form action= "" id= "form" >
<table style= "width:80%;height:80%;" border= "1" cellspacing= "0" cellpadding= "0" align= "center" valign= "Middle" >
<tr>
<textarea rows= "10%" name= "content" id= "content" style= "width:100%;height:30%;" >
</textarea>
<div id= "abc" align= "Center" >
<input class= "button" name= "button" id= "button" type= "button" value= "Commit" onclick= "Save ()"/>
<input class= "button" name= "reset" id= "reset" type= "reset" value= "reset"/>
</div>
</tr>
</table>
</form>

JS in the Save method:

function Save () {
document.getElementById (' button '). disabled=true;
var content= document.getelementbyid (' content '). Value;
if (lefttrim (content) = = "") {
Alert ("Content cannot be empty");
document.getElementById (' button '). Disabled=false;
return false;
}
var data = {};
Data.body = {
Messagesql:content,
};
var Titlej = json.stringify (data);

$.ajax ({
URL: "/base/dboperation/operation",
Type: "POST",
DataType: "JSON",
ContentType: "Application/json",
Data:titlej,
Success:function (res) {
var retjson=json.stringify (res);
var evalue =eval (' (' +retjson+ ') ');
var error=evalue["errors"];
alert (error);
document.getElementById (' button '). Disabled=false;
$ (' #response '). Val (Error);
},
Error:function () {
Alert ("Return failed!");
document.getElementById (' button '). Disabled=false;
}
});
}

button to prevent duplicate submissions (click Submit after the Submit button dimmed, after the operation has been completed recovery)

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.