O'Reilly logo

HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition by Bruce Hyslop, Elizabeth Castro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Disabling Form Elements

In some cases, you may not want visitors to use certain parts of your form. For example, you might want to disable a submit button until all the required fields have been filled out Image.

Image Here, I use JavaScript and the disabled attribute to make the Other text area inaccessible until the Other radio button is selected.

<li>     <input type="radio" name="how" value="facebook" id="facebook" onclick="document.getElementById('other_description').disabled = true;" />     <label for="facebook">Facebook</label></li><li>     <input ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required