Switch to full style
JavaScript code examples
Post a reply

avoid multiple submit clicks using javascript

Thu Jan 17, 2013 1:44 am

Prevent multiple form's submissions on your website using javascript.
javascript code
<html>
<head>
<title>avoid multiple submit Example</title>

<script type="text/javascript">
var submitIsPressed = false;
function WasteTime() {
//' Sleeping to 10 seconds

}
function checkBeforeSubmit(){

if(!submitIsPressed) {
document.getElementById("buttonSub").disabled="disabled";
setTimeout('WasteTime()', 10000);// As loading-Remove this line

submitIsPressed = true;

return submitIsPressed;
}


return false;
}


</script>



</head>
<body>
<center>
<form action="#" method="POST" onsubmit="return checkBeforeSubmit()">
<table border="1">
<tr>
<td><strong>username:</strong></td><td><input type="text" name="username" />
</tr>
<tr>
<td><strong>password:</strong></td><td><input type="text" name="password" />
</tr>
<tr>
<td colspan="2">
<center><input type="submit" value="submit" id="buttonSub" />
</td>

</form>
</center>

</body>

</html>




Post a reply
  Related Posts  to : avoid multiple submit clicks using javascript
 avoid multiple submit of form, prevent more than one press     -  
 Javascript Validation On Multiple Select Lists     -  
 get time difference between to mouse-clicks-double clicks     -  
 Disable submit button until all form's fields are filled     -  
 How Can I Avoid Domain Renewal Problems?     -  
 avoid showing/printing figures, text after conclusion     -  
 show the locations of clicks on the image     -  
 draw any number of lines on mouse clicks     -  
 draw any number of circles using mouse clicks     -  
 Applet get mouse clicks and draw circle     -  

Topic Tags

JavaScript Validation