Total members 11893 |It is currently Mon Nov 04, 2024 11:23 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  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
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com