Submitting Disabled Fields

Published May 26, 2009

The "disabled" attribute for form fields is a great little user interface helper that you can use to help protect data from accidental changes. It locks down an HTML input form element so that it can be viewed, but not be changed. This is handy when displaying a form to a user where you need an extra layer of protection for the data.

What happens when the user goes to submit a form with disabled elements? The value of the disabled elements are not passed back to the browser - this can quickly turn into a data validation and/or submission issue.

Luckily, there's a quick way to fix this with a bit of jQuery. With just 3 lines of code, you can enabled (un-disable?) all fields on the form when the user clicks the "submit" button:

$('input#edit-submit').click(function() {

You'll probably want to modify this code a little bit to better target the disabled elements, but this should get you going in the right direction.


Does this still work?

Submitted by Guest (not verified) on Tue, 09/17/2013 - 11:39

Author comment

Yes - this should still work fine.


Submitted by ultimike on Tue, 09/17/2013 - 11:42

In reply to by Guest (not verified)

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!