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.
The problem is that input elements don’t have an “onload” event. The spec shows the available events as:
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: