Disable all form controls on a web page

css, forms, html, jquery

Solution

$("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.

Problem

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.

Original source

Related problems