Skip to content

Commit 1ac878d

Browse files
committed
version bump
1 parent 329c995 commit 1ac878d

39 files changed

+186
-64
lines changed

form-validator/brazil.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/file.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/html5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jquery.form-validator.js

Lines changed: 136 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,127 @@
1717
/** File generated by Grunt -- do not modify
1818
* JQUERY-FORM-VALIDATOR
1919
*
20-
* @version 2.3.41
20+
* @version 2.3.43
2121
* @website http://formvalidator.net/
2222
* @author Victor Jonsson, http://victorjonsson.se
2323
* @license MIT
2424
*/
25+
/**
26+
*/
27+
(function ($, undefined) {
28+
29+
var disableFormSubmit = function () {
30+
return false;
31+
},
32+
HaltManager = {
33+
numHalted: 0,
34+
haltValidation: function($form) {
35+
this.numHalted++;
36+
$.formUtils.haltValidation = true;
37+
$form
38+
.unbind('submit', disableFormSubmit)
39+
.bind('submit', disableFormSubmit)
40+
.find('*[type="submit"]')
41+
.addClass('disabled')
42+
.attr('disabled', 'disabled');
43+
},
44+
unHaltValidation: function($form) {
45+
this.numHalted--;
46+
if (this.numHalted === 0) {
47+
$.formUtils.haltValidation = false;
48+
$form
49+
.unbind('submit', disableFormSubmit)
50+
.find('*[type="submit"]')
51+
.removeClass('disabled')
52+
.removeAttr('disabled', 'disabled');
53+
}
54+
}
55+
};
56+
57+
function AsyncValidation($form, $input) {
58+
this.$form = $form;
59+
this.$input = $input;
60+
this.reset();
61+
}
62+
63+
AsyncValidation.prototype.reset = function() {
64+
this.haltedFormValidation = false;
65+
this.hasRun = false;
66+
this.isRunning = false;
67+
this.result = undefined;
68+
};
69+
70+
AsyncValidation.prototype.run = function(eventContext, callback) {
71+
if (eventContext === 'keyup') {
72+
return null;
73+
} else if (this.isRunning) {
74+
if (!this.haltedFormValidation && eventContext === 'submit') {
75+
HaltManager.haltValidation();
76+
this.haltedFormValidation = true;
77+
}
78+
return null; // Waiting for result
79+
} else if(this.hasRun) {
80+
this.$input.one('keyup paste', this.reset.bind(this));
81+
return this.result;
82+
} else {
83+
if (eventContext === 'submit') {
84+
HaltManager.haltValidation(this.$form);
85+
this.haltedFormValidation = true;
86+
}
87+
this.isRunning = true;
88+
this.$input
89+
.attr('disabled', 'disabled')
90+
.addClass('async-validation');
91+
this.$form.addClass('async-validation');
92+
93+
callback(function(result) {
94+
this.done(result);
95+
}.bind(this));
96+
97+
return null;
98+
}
99+
};
100+
101+
AsyncValidation.prototype.done = function(result) {
102+
this.result = result;
103+
this.hasRun = true;
104+
this.isRunning = false;
105+
this.$input
106+
.removeAttr('disabled')
107+
.removeClass('async-validation');
108+
this.$form.removeClass('async-validation');
109+
if (this.haltedFormValidation) {
110+
HaltManager.unHaltValidation(this.$form);
111+
this.$form.trigger('submit');
112+
} else {
113+
this.$input.trigger('validation.revalidate');
114+
}
115+
};
116+
117+
$.formUtils = $.extend($.formUtils || {}, {
118+
asyncValidation: function(validatorName, $input, $form) {
119+
// Return async validator attached to this input element
120+
// or create a new async validator and attach it to the input
121+
var asyncValidation,
122+
input = $input.get(0);
123+
124+
if (!input.asyncValidators) {
125+
input.asyncValidators = {};
126+
}
127+
128+
if (input.asyncValidators[validatorName]) {
129+
asyncValidation = input.asyncValidators[validatorName];
130+
} else {
131+
asyncValidation = new AsyncValidation($form, $input);
132+
input.asyncValidators[validatorName] = asyncValidation;
133+
}
134+
135+
return asyncValidation;
136+
}
137+
});
138+
139+
})(jQuery);
140+
25141
/**
26142
* Deprecated functions and attributes
27143
* @todo: Remove in release of 3.0
@@ -226,7 +342,7 @@
226342

227343
// Remove error messages in top of form
228344
if (typeof conf.submitErrorMessageCallback === 'function') {
229-
var $errorMessagesInTopOfForm = conf.submitErrorMessageCallback($form, conf);
345+
var $errorMessagesInTopOfForm = conf.submitErrorMessageCallback($form, false, conf);
230346
if ($errorMessagesInTopOfForm) {
231347
$errorMessagesInTopOfForm.html('');
232348
}
@@ -511,20 +627,20 @@
511627
* @param {Object} [language] Optional, will override $.formUtils.LANG
512628
* @param {Object} [conf] Optional, will override the default settings
513629
* @param {Boolean} attachKeyupEvent Optional
514-
* @param {String} eventType
630+
* @param {String} eventContext
515631
* @return {jQuery}
516632
*/
517-
$.fn.validateInputOnBlur = function (language, conf, attachKeyupEvent, eventType) {
633+
$.fn.validateInputOnBlur = function (language, conf, attachKeyupEvent, eventContext) {
518634

519-
$.formUtils.eventType = eventType;
635+
$.formUtils.eventType = eventContext;
520636

521637
if ( this.willPostponeValidation() ) {
522638
// This validation has to be postponed
523639
var _self = this,
524640
postponeTime = this.valAttr('postpone') || 200;
525641

526642
window.postponedValidation = function () {
527-
_self.validateInputOnBlur(language, conf, attachKeyupEvent, eventType);
643+
_self.validateInputOnBlur(language, conf, attachKeyupEvent, eventContext);
528644
window.postponedValidation = false;
529645
};
530646

@@ -547,9 +663,19 @@
547663
language,
548664
conf,
549665
$form,
550-
eventType
666+
eventContext
551667
);
552668

669+
var reValidate = function() {
670+
$elem.validateInputOnBlur(language, conf, false, 'blur.revalidated');
671+
};
672+
673+
if (eventContext === 'blur') {
674+
$elem
675+
.unbind('validation.revalidate', reValidate)
676+
.one('validation.revalidate', reValidate);
677+
}
678+
553679
if (attachKeyupEvent) {
554680
$elem.removeKeyUpValidation();
555681
}
@@ -747,10 +873,8 @@
747873
$.formUtils.isValidatingEntireForm = false;
748874

749875
// Validation failed
750-
if (!$.formUtils.haltValidation && errorInputs.length > 0) {
751-
876+
if (errorInputs.length > 0) {
752877
if (displayError) {
753-
754878
if (conf.errorMessagePosition === 'top') {
755879
$.formUtils.dialogs.setMessageInTopOfForm($form, errorMessages, conf, language);
756880
} else {
@@ -761,17 +885,14 @@
761885
if (conf.scrollToTopOnError) {
762886
$.formUtils.$win.scrollTop($form.offset().top - 20);
763887
}
764-
765888
}
766-
767-
return false;
768889
}
769890

770891
if (!displayError && $.formUtils.haltValidation) {
771892
$.formUtils.errorDisplayPreventedWhenHalted = true;
772893
}
773894

774-
return !$.formUtils.haltValidation;
895+
return errorInputs.length === 0 && !$.formUtils.haltValidation;
775896
};
776897

777898
/**
@@ -1074,7 +1195,6 @@
10741195
}
10751196

10761197
var valid = $form.isValid(conf.language, conf);
1077-
10781198
if ($.formUtils.haltValidation) {
10791199
// Validation got halted by one of the validators
10801200
return stop();
@@ -1321,7 +1441,7 @@
13211441

13221442
if (eventContext !== 'keyup' || validator.validateOnKeyUp) {
13231443
// A validator can prevent itself from getting triggered on keyup
1324-
isValid = validator.validatorFunction(value, $elem, conf, language, $form);
1444+
isValid = validator.validatorFunction(value, $elem, conf, language, $form, eventContext);
13251445
}
13261446

13271447
if (!isValid) {

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jsconf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** File generated by Grunt -- do not modify
22
* JQUERY-FORM-VALIDATOR
33
*
4-
* @version 2.3.41
4+
* @version 2.3.43
55
* @website http://formvalidator.net/
66
* @author Victor Jonsson, http://victorjonsson.se
77
* @license MIT

form-validator/lang/ca.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/cs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/da.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/de.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/fr.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/it.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/nl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/no.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pt.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ro.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ru.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)