|
5 | 5 | * |
6 | 6 | * @website http://formvalidator.net/ |
7 | 7 | * @license Dual licensed under the MIT or GPL Version 2 licenses |
8 | | - * @version 2.2.60 |
| 8 | + * @version 2.2.61 |
9 | 9 | */ |
10 | 10 | (function ($) { |
11 | 11 |
|
|
116 | 116 | $form.children().eq(0).before(container); |
117 | 117 | }; |
118 | 118 |
|
| 119 | + |
119 | 120 | /** |
120 | 121 | * Assigns validateInputOnBlur function to elements blur event |
121 | 122 | * |
|
216 | 217 | return this; |
217 | 218 | }; |
218 | 219 |
|
| 220 | + /** |
| 221 | + * @param {Function} cb |
| 222 | + * @param {Object} [conf] |
| 223 | + * @param {Object} [lang] |
| 224 | + */ |
| 225 | + $.fn.validate = function(cb, conf, lang) { |
| 226 | + var language = $.extend({}, $.formUtils.LANG, lang || {}); |
| 227 | + this.each(function() { |
| 228 | + var $elem = $(this); |
| 229 | + $elem.one('validation', function(evt, isValid) { |
| 230 | + cb(isValid, this, evt); |
| 231 | + }); |
| 232 | + $elem.validateInputOnBlur( |
| 233 | + language, |
| 234 | + $.extend({}, $elem.closest('form').get(0).validationConfig, conf || {}) |
| 235 | + ); |
| 236 | + }); |
| 237 | + }; |
| 238 | + |
| 239 | + /** |
| 240 | + * Tells whether or not validation of this input will have to postpone the form submit () |
| 241 | + * @returns {Boolean} |
| 242 | + */ |
| 243 | + $.fn.willPostponeValidation = function() { |
| 244 | + return (this.valAttr('suggestion-nr') || |
| 245 | + this.valAttr('postpone') || |
| 246 | + this.hasClass('hasDatepicker')) |
| 247 | + && !window.postponedValidation; |
| 248 | + }; |
| 249 | + |
219 | 250 | /** |
220 | 251 | * Validate single input when it loses focus |
221 | 252 | * shows error message in a span element |
|
231 | 262 |
|
232 | 263 | $.formUtils.eventType = eventType; |
233 | 264 |
|
234 | | - if ((this.valAttr('suggestion-nr') || this.valAttr('postpone') || this.hasClass('hasDatepicker')) && !window.postponedValidation) { |
| 265 | + if ( this.willPostponeValidation() ) { |
235 | 266 | // This validation has to be postponed |
236 | 267 | var _self = this, |
237 | 268 | postponeTime = this.valAttr('postpone') || 200; |
|
0 commit comments