|
198 | 198 | * @return {jQuery}
|
199 | 199 | */
|
200 | 200 | $.fn.validateInputOnBlur = function(language, conf, attachKeyupEvent, eventType) {
|
| 201 | + |
201 | 202 | $.formUtils.eventType = eventType;
|
202 | 203 |
|
203 | 204 | if( (this.valAttr('suggestion-nr') || this.valAttr('postpone') || this.hasClass('hasDatepicker')) && !window.postponedValidation ) {
|
|
274 | 275 | };
|
275 | 276 |
|
276 | 277 | /**
|
277 |
| - * Function that validate all inputs in given element |
| 278 | + * Function that validates all inputs in active form |
278 | 279 | *
|
279 | 280 | * @param {Object} [language]
|
280 | 281 | * @param {Object} [conf]
|
|
316 | 317 | }
|
317 | 318 | },
|
318 | 319 |
|
| 320 | + /** HoldsInputs already validated, to prevent recheck of mulitple checkboxes & radios */ |
| 321 | + checkedInputs = [], |
| 322 | + |
319 | 323 | /** Error messages for this validation */
|
320 | 324 | errorMessages = [],
|
321 | 325 |
|
|
349 | 353 | $form.find('input,textarea,select').filter(':not([type="submit"],[type="button"])').each(function() {
|
350 | 354 | var $elem = $(this);
|
351 | 355 | var elementType = $elem.attr('type');
|
352 |
| - if (!ignoreInput($elem.attr('name'), elementType)) { |
353 |
| - |
354 |
| - var validation = $.formUtils.validateInput( |
355 |
| - $elem, |
356 |
| - language, |
357 |
| - conf, |
358 |
| - $form, |
359 |
| - 'submit' |
360 |
| - ); |
361 |
| - |
362 |
| - // Run element validation callback |
363 |
| - if( typeof conf.onElementValidate == 'function' ) { |
364 |
| - conf.onElementValidate((validation === true), $elem, $form, validation); |
365 |
| - } |
366 |
| - |
367 |
| - if(validation !== true) { |
368 |
| - addErrorMessage(validation, $elem); |
369 |
| - } else { |
370 |
| - $elem |
371 |
| - .valAttr('current-error', false) |
372 |
| - .addClass('valid') |
373 |
| - .parent() |
374 |
| - .addClass('has-success'); |
375 |
| - } |
| 356 | + var elementName = $elem.attr('name'); |
| 357 | + if (!ignoreInput(elementName, elementType)) { |
| 358 | + |
| 359 | + // do not recheck multiple elements with same name, i.e. checkboxes, radios |
| 360 | + if ($.inArray(elementName, checkedInputs) < 0 ) { |
| 361 | + checkedInputs.push(elementName); |
| 362 | + |
| 363 | + var validation = $.formUtils.validateInput( |
| 364 | + $elem, |
| 365 | + language, |
| 366 | + conf, |
| 367 | + $form, |
| 368 | + 'submit' |
| 369 | + ); |
| 370 | + |
| 371 | + // Run element validation callback |
| 372 | + if( typeof conf.onElementValidate == 'function' ) { |
| 373 | + conf.onElementValidate((validation === true), $elem, $form, validation); |
| 374 | + } |
| 375 | + |
| 376 | + if(validation !== true) { |
| 377 | + addErrorMessage(validation, $elem); |
| 378 | + } else { |
| 379 | + $elem |
| 380 | + .valAttr('current-error', false) |
| 381 | + .addClass('valid') |
| 382 | + .parent() |
| 383 | + .addClass('has-success'); |
| 384 | + } |
| 385 | + |
| 386 | + } |
| 387 | + |
376 | 388 | }
|
377 | 389 |
|
378 | 390 | });
|
|
853 | 865 | var validator = $.formUtils.validators[rule];
|
854 | 866 |
|
855 | 867 | if( validator && typeof validator['validatorFunction'] == 'function' ) {
|
| 868 | + |
856 | 869 | // special change of element for checkbox_group rule
|
857 | 870 | if ( rule == 'validate_checkbox_group' ) {
|
858 |
| - // set element to first in group, so error msg is set only once |
| 871 | + // set element to first in group, so error msg attr doesn't need to be set on all elements in group |
859 | 872 | $elem = $("[name='"+$elem.attr('name')+"']:eq(0)");
|
860 | 873 | }
|
861 |
| - |
| 874 | + |
862 | 875 | var isValid = null;
|
863 | 876 | if( eventContext != 'keyup' || validator.validateOnKeyUp ) {
|
864 | 877 | isValid = validator.validatorFunction(value, $elem, conf, language, $form);
|
|
0 commit comments