disable the submit button when clicked

Hi all,
  I have a form where I want the submit button to be disabled when the user has click on it. This is because the process is quite long and I want to avoid the impatient users from clicking on it again...

In my form I have some javascript validations exemple
<form blabla on submit validation form...>
When the submit button is click, the form is being validated if all good then the process begins. But before returning to the next page it's quite long like I said.. so can I do something like

<input type="submit" name="go" value="save" onclick="javascript:<disable my button at this point"> ?

Thanks for the answer

LVL 1
DaDManAsked:
Who is Participating?
 
BustaroomsConnect With a Mentor Commented:
in that case i would move it

<form name="yourform" onsubmit="this.go.disabled=true;return validation();">
0
 
intrwrksCommented:
Try this out:

<input type="submit" name="go" value="save" onclick="javascript:this.setAttribute('disabled','true');">
0
 
BustaroomsCommented:
<input type="submit" name="go" value="save" onclick="this.disabled=true;">

be sure to re-enable the button if your javascript validations finds an error

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
BustaroomsCommented:
and the re-enable would be

function validation(){
...... all your validation crap .....

.......... whoa somethings wrong .........
 alert('You idiot you filled out the form wrong. Do it again');
 document.yourFormName.go.disabled=false;


}

0
 
DaDManAuthor Commented:
Hey guys your on the spot. This is what I want but I have a problem now... the button is disable but does not submit anything.. just stand there.. disabled!! :-)

Any ideas?
0
 
DaDManAuthor Commented:
and this is for both method you've offered...
0
 
devicCommented:
try this:
============
<input type="submit" name="go" value="save" onclick="this.disabled=true;this.form.submit();">
0
 
DaDManAuthor Commented:
yeah man!! right on.

Thanks alot

0
 
kahkahaCommented:
but there is a specific problem with the code
<input type="submit" name="go" value="save" onclick="this.disabled=true;this.form.submit();">

this arises when you control the variable go, for example with PHP. Its value comes null or zero. thats why if you check the form's submittal by checking the button's value, PHP does not understand naturally that the form is submitted. if the button is disabled when submitting, its value transmits as zero or null
0
 
devicCommented:
hi kahkaha,

then maybe this one:
=================
<form action=http://www.sembel.net/tools/q.php>
      <input type=text name=kuku value=hurra>
      <input type="submit" name="go" value="save" onclick="this.onclick=function(){return false};this.form.submit();">
</form>


btw, you need open a new question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.