views:

96

answers:

1

What is the nicest way to disable all form controls on a web page? I have read that this cannot be done via CSS but this would be my preferred option if possible. I also have access to jQuery if that makes life easier.

+5  A: 
$("form :input").attr("disabled","disabled");

:input selects all form controls, including input, textarea, select and button elements.

If you want to disable form elements that are outside of forms too, simply omit the 'form` selector from the above.

karim79