client_side_validations 3.2.1, client_side_validation-simple_form 2.0.0 not work #434

jerryshen opened this Issue Nov 12, 2012 · 6 comments

2 participants


I'm using simple form with client side validations, when i add validate: true in form, it generates data-validate true for all fields (even that field is optional in model validations).

Really Need some help

fn = context[kind];
if (validators[kind]) {
_ref = validators[kind];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
validator = _ref[_i];
if (message =, element, validator)) {
valid = failElement(message);

TypeError: validators is undefined


What version of Rails?


Sorry, for now it's ok. the error is gone, my rails version is 3.2.8
but I have another problem.

I have the following code

= simple_nested_form_for resource, url: url, validate: true do |f|
  = f.input :cusip, validate: { presence: true }

it seems like cusip doesn't trigger the presence validation

<input type="text" size="50" placeholder="i.e. 90000" name="deals_bond[cusip]" id="deals_bond_cusip" class="string optional" data-validate="true">

the html is right I think


Is the presence validator on the model? Putting validate: { :presence => true } on the input doesn't add the validation


I see what you mean,
But if I have two forms with one model, one needs this presence validator, the other do not. how to handle this?
Thanks @bcardarella


You can turn off the validation for the form that doesn't need it:

validate: { presence: false }

Please understand that this doesn't stop your model from running the validation on the server, it just tells ClientSideValidations to not include this particular validation rule for this one instance


That's what I want, for model it's easy to handle, just pass a hidden attribute

Thanks @bcardarella it really helps me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment