Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make configurable which inputs validateForm will validate #454

Merged
merged 1 commit into from

3 participants

@kirel

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]'
@markets

:+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.

@bcardarella
Owner

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

@bcardarella
Owner

actually, not much to review. Pulling in.

@bcardarella bcardarella merged commit 1f07ef0 into DavyJonesLocker:3-2-stable
@markets

thanks guys!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
This page is out of date. Refresh to see the latest.
View
3  coffeescript/rails.validations.coffee
@@ -38,7 +38,7 @@ validateForm = (form, validators) ->
form.trigger('form:validate:before.ClientSideValidations')
valid = true
- form.find(':input:enabled:visible[data-validate]').each ->
+ form.find(ClientSideValidations.selectors.validate_inputs).each ->
valid = false unless $(@).isValid(validators)
# we don't want the loop to break out by mistake
true
@@ -108,6 +108,7 @@ if window.ClientSideValidations.forms == undefined
window.ClientSideValidations.selectors =
inputs: ':input:not(button):not([type="submit"])[name]:visible:enabled'
+ validate_inputs: ':input:enabled:visible[data-validate]'
forms: 'form[data-validate]'
window.ClientSideValidations.reset = (form) ->
View
3  vendor/assets/javascripts/rails.validations.js
@@ -48,7 +48,7 @@
var valid;
form.trigger('form:validate:before.ClientSideValidations');
valid = true;
- form.find(':input:enabled:visible[data-validate]').each(function() {
+ form.find(ClientSideValidations.selectors.validate_inputs).each(function() {
if (!$(this).isValid(validators)) {
valid = false;
}
@@ -128,6 +128,7 @@
window.ClientSideValidations.selectors = {
inputs: ':input:not(button):not([type="submit"])[name]:visible:enabled',
+ validate_inputs: ':input:enabled:visible[data-validate]',
forms: 'form[data-validate]'
};
Something went wrong with that request. Please try again.