This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Disabling Submit Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disabling Submit Button" Watch "Disabling Submit Button" New topic

Disabling Submit Button

Kashyap Jani

Joined: Dec 04, 2002
Posts: 1
I have a submit button image which i need to disable once pressed. I can disable an normal image but not the submit button. I'm using the following code to disable the image :
But the above code doesn't work for input type=image button. Is there anyway i can disable the submit button so that the user does not click submit the form twice.
Any help would be appreciated.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15379
I personally would use an input button
you can use a session cookie with this script too.
Note take the _ out of on_click
var AllowIt=true;
function SubIt(){
alert('This form should only be submitted once');
<form name="formname">
<input type="button" value="submit" name="Button" on_click="subIt()">
It is sorta covered in the JavaRanch Style Guide.
subject: Disabling Submit Button