JavaScript to enable "submit" button (doesn't work)

javascript

Solution

The problem is that input elements don't have an "onload" event. The spec shows the available events as:

  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  onselect    %Script;       #IMPLIED  -- some text was selected --
  onchange    %Script;       #IMPLIED  -- the element value was changed --
  onclick     %Script;       #IMPLIED  -- a pointer button was clicked --
  ondblclick  %Script;       #IMPLIED  -- a pointer button was double clicked--
  onmousedown %Script;       #IMPLIED  -- a pointer button was pressed down --
  onmouseup   %Script;       #IMPLIED  -- a pointer button was released --
  onmouseover %Script;       #IMPLIED  -- a pointer was moved onto --
  onmousemove %Script;       #IMPLIED  -- a pointer was moved within --
  onmouseout  %Script;       #IMPLIED  -- a pointer was moved away --
  onkeypress  %Script;       #IMPLIED  -- a key was pressed and released --
  onkeydown   %Script;       #IMPLIED  -- a key was pressed down --
  onkeyup     %Script;       #IMPLIED  -- a key was released --

Since it doesn't appear as though any of those will help you, you're probably best off to add the event to the onload of the body element (or through a more robust means, like jQuery's document ready function). Here's the quick hack way to do it:

<body onload="document.getElementById('post-comment').disabled=false">

Problem

I need the button "submit" to be disabled unless JavaScript is on. I tried: 1. ``` <input onLoad="this.disabled=false" id="post-comment" type="submit" value="Post Your Comment" disabled="disabled"/> ``` 2. ``` <input onLoad="this.removeAttribute('disabled');" id="post-comment" type="submit" value="Post Your Comment" disabled="disabled"/> ``` 3. ``` <input onLoad="document.getElementById('post-comment').removeAttribute('disabled');" id="post-comment" type="submit" value="Post Your Comment" disabled="disabled"/> ``` Doesn't work. I'm new to JavaScript, but can't find answer on the net.

Original source