Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Make configurable which inputs validateForm will validate #454

Merged
merged 1 commit into from over 1 year ago

3 participants

Daniel Kirsch Marc Anguera Insa Brian Cardarella
Daniel Kirsch

I needed validation of disabled form fields which is impossible since #177 was closed. This lets me enable it via setting

ClientSideValidations.selectors.inputs = ':input:not(button):not([type="submit"])[name]:visible'
ClientSideValidations.selectors.validate_inputs = ':input:visible[data-validate]'
Marc Anguera Insa

:+1: nice stuff @kirel, I need something very similar. I use select2 and selects becomes invisible ('display: none'), so these inputs are ignored by now.

Brian Cardarella
Owner

Strange I never got an email about this PR. I'll check it out over the weekend, pretty slammed right now :p

Brian Cardarella
Owner

actually, not much to review. Pulling in.

Brian Cardarella bcardarella merged commit 1f07ef0 into from January 03, 2013
Brian Cardarella bcardarella closed this January 03, 2013
Marc Anguera Insa

thanks guys!!

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

Showing 1 unique commit by 1 author.

Dec 30, 2012
Daniel Kirsch Make configurable which inputs validateForm will validate a2e2c2a
This page is out of date. Refresh to see the latest.
3  coffeescript/rails.validations.coffee
@@ -38,7 +38,7 @@ validateForm = (form, validators) ->
38 38
   form.trigger('form:validate:before.ClientSideValidations')
39 39
 
40 40
   valid = true
41  
-  form.find(':input:enabled:visible[data-validate]').each ->
  41
+  form.find(ClientSideValidations.selectors.validate_inputs).each ->
42 42
     valid = false unless $(@).isValid(validators)
43 43
     # we don't want the loop to break out by mistake
44 44
     true
@@ -108,6 +108,7 @@ if window.ClientSideValidations.forms == undefined
108 108
 
109 109
 window.ClientSideValidations.selectors =
110 110
   inputs: ':input:not(button):not([type="submit"])[name]:visible:enabled'
  111
+  validate_inputs: ':input:enabled:visible[data-validate]'
111 112
   forms:  'form[data-validate]'
112 113
 
113 114
 window.ClientSideValidations.reset = (form) ->
3  vendor/assets/javascripts/rails.validations.js
@@ -48,7 +48,7 @@
48 48
     var valid;
49 49
     form.trigger('form:validate:before.ClientSideValidations');
50 50
     valid = true;
51  
-    form.find(':input:enabled:visible[data-validate]').each(function() {
  51
+    form.find(ClientSideValidations.selectors.validate_inputs).each(function() {
52 52
       if (!$(this).isValid(validators)) {
53 53
         valid = false;
54 54
       }
@@ -128,6 +128,7 @@
128 128
 
129 129
   window.ClientSideValidations.selectors = {
130 130
     inputs: ':input:not(button):not([type="submit"])[name]:visible:enabled',
  131
+    validate_inputs: ':input:enabled:visible[data-validate]',
131 132
     forms: 'form[data-validate]'
132 133
   };
133 134
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.