|
Copied To Clipboard!
<html>
<head>
<title>Disable Form Button Javascript Code Snippet</title>
<script>
/* Begin Disable Form Button
== This Script Free To Use Providing This Notice Remains ==
== This Script Has Been Found In The http://www.SnapBuilder.com Free Public Codes Library ==
== NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply ==
== Created by: Justin Barlow : http://www.netlobo.com : Creative Commons License ==
*/
function disableSubmit(whichButton) {
if (document.getElementById) {
// this is the way the standards work
document.getElementById(whichButton).disabled = true;
} else if (document.all) {
// this is the way old msie versions work
document.all[whichButton].disabled = true;
} else if (document.layers) {
// this is the way nn4 works
document.layers[whichButton].disabled = true;
}
}
</script>
</head>
<body>
<p>This script will disable your submit button in order to prevent multiple form submissions.</p>
<form method="post" action="yourProcessingScript.php" onsubmit="return disableSubmit('mFormSubmit')">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name="message" rows="4" cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><input type="submit" name="submit" id="mFormSubmit" value="Send Message"></td>
</tr>
</table>
</form>
</body>
</html>
|