Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


validates disabled fields #177

taavo opened this Issue · 0 comments

2 participants


Client_side_validations validates disabled fields. This causes problems for forms like the following:


= semantic_form_for @contact, :validate => true do |f|
  = f.input :first_name, :input_html => {:disabled => 'disabled'}
  = f.input :last_name
  = f.submit


class Contact < ActiveRecord::Base
  validates :first_name, :presence => true
  validates :last_name, :presence => true

In this case, the form can't be submitted, because the first_name field, even though it's disabled (and therefore wouldn't be submitted to the server anyway), is blank and therefore invalid. If that field is removed from the form entirely, however, the form submits just fine.

(Why would someone want to do this? In this example, we only let the user modify the first_name field if certain conditions are set by javascript, in which case we remove the disabled attribute.)

This can be worked around by using javascript to remove the validation on fields when you add the disabled attribute, and putting it back when you remove the disabled attribute.

In my opinion, instead of requiring workarounds like the above, client_side_validations should just ignore fields if they're disabled, just like the server does. I'll be attaching a quick patch to demonstrate this fix. Thanks.

@joker-777 joker-777 referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kirel kirel referenced this issue from a commit in kirel/client_side_validations
@bcardarella bcardarella Do not validate disabled inputs
Closes #177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.