Skip to content

Commit 37e2eb5

Browse files
Merge pull request victorjonsson#563 from jfrondeau/master
Fix victorjonsson#444: Make 'valid' class configurable
2 parents 6dfdccd + 81dc4a6 commit 37e2eb5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

form-validator/jquery.form-validator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
applyInputErrorStyling: function ($input, conf) {
297297
$input
298298
.addClass(conf.errorElementClass)
299-
.removeClass('valid');
299+
.removeClass(conf.successElementClass);
300300

301301
this.getParentContainer($input)
302302
.addClass(conf.inputParentClassOnError)
@@ -315,7 +315,7 @@
315315

316316
// Reset input css
317317
$input
318-
.removeClass('valid')
318+
.removeClass(conf.successElementClass)
319319
.removeClass(conf.errorElementClass)
320320
.css('border-color', '');
321321

@@ -352,7 +352,7 @@
352352
}
353353

354354
// Remove input css/messages
355-
$form.find('.' + conf.errorElementClass + ',.valid').each(function() {
355+
$form.find('.' + conf.errorElementClass + ',.' + conf.successElementClass).each(function() {
356356
dialogs.removeInputStylingAndMessage($(this), conf);
357357
});
358358
},

src/main/dialogs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
applyInputErrorStyling: function ($input, conf) {
4545
$input
4646
.addClass(conf.errorElementClass)
47-
.removeClass('valid');
47+
.removeClass(conf.successElementClass);
4848

4949
this.getParentContainer($input)
5050
.addClass(conf.inputParentClassOnError)
@@ -63,7 +63,7 @@
6363

6464
// Reset input css
6565
$input
66-
.removeClass('valid')
66+
.removeClass(conf.successElementClass)
6767
.removeClass(conf.errorElementClass)
6868
.css('border-color', '');
6969

@@ -100,7 +100,7 @@
100100
}
101101

102102
// Remove input css/messages
103-
$form.find('.' + conf.errorElementClass + ',.valid').each(function() {
103+
$form.find('.' + conf.errorElementClass + ',.' + conf.successElementClass).each(function() {
104104
dialogs.removeInputStylingAndMessage($(this), conf);
105105
});
106106
},

src/main/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
return {
1919
ignore: [], // Names of inputs not to be validated even though `validationRuleAttribute` containing the validation rules tells us to
2020
errorElementClass: 'error', // Class that will be put on elements which value is invalid
21+
successElementClass: 'valid', // Class that will be put on elements that has been validated with success
2122
borderColorOnError: '#b94a48', // Border color of elements which value is invalid, empty string to not change border color
2223
errorMessageClass: 'form-error', // class name of div containing error messages when validation fails
2324
validationRuleAttribute: 'data-validation', // name of the attribute holding the validation rules

0 commit comments

Comments
 (0)