Web Hosting
We've partnered with HostGator for reliable, affordable hosting starting at $3.95/mon. Use coupon code "javascriptkit25" for 25% off any package.

The disabled attribute of HTML 4

First and foremost, let's look at the disabled attribute, an attribute for form elements found in HTML 4. With it, you can disable any form element (the element appears grayed out and unclickable). Take a look at the following example:

Try submitting the above form...I'm waiting. As hard as you may try, and assuming you're using IE 4 or above (since the disabled attribute is only supported in IE 4+/Firefox), there simply is no way you could submit the form, since I "disabled" the submit button. Here's the entire source code to the above form:

<input type="text" size="20" value="Can't submit this!">
<input type="submit" value="Submit" name="B1" disabled="disabled">

Simply by adding the attribute "disabled" to the input element, it disables the element. You can add the disabled attribute to any form element to disable that particular element. Here are some more examples:

As cool as disabling an element is, I hope that's not all you have in mind (I don't know, you might want to re-enable it). Actually, that better not be all you have in mind! You see, the disabled attribute is one of those attributes that are pretty much useless without the help of it's cousin- JavaScript. Only JavaScript can bring elements cursed by this attribute back to life, and that's why JavaScript rules (no offense, HTML gurus).

Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.