|
1 | 1 | /*!
|
2 |
| - * jQuery Validation Plugin v1.20.0 |
| 2 | + * jQuery Validation Plugin v1.21.0 |
3 | 3 | *
|
4 | 4 | * https://jqueryvalidation.org/
|
5 | 5 | *
|
6 |
| - * Copyright (c) 2023 Jörn Zaefferer |
| 6 | + * Copyright (c) 2024 Jörn Zaefferer |
7 | 7 | * Released under the MIT license
|
8 | 8 | */
|
9 | 9 | (function( factory ) {
|
@@ -293,6 +293,7 @@ $.extend( $.validator, {
|
293 | 293 | onsubmit: true,
|
294 | 294 | ignore: ":hidden",
|
295 | 295 | ignoreTitle: false,
|
| 296 | + customElements: [], |
296 | 297 | onfocusin: function( element ) {
|
297 | 298 | this.lastActive = element;
|
298 | 299 |
|
@@ -440,17 +441,17 @@ $.extend( $.validator, {
|
440 | 441 | settings[ eventType ].call( validator, this, event );
|
441 | 442 | }
|
442 | 443 | }
|
443 |
| - |
| 444 | + var focusListeners = [ ":text", "[type='password']", "[type='file']", "select", "textarea", "[type='number']", "[type='search']", |
| 445 | + "[type='tel']", "[type='url']", "[type='email']", "[type='datetime']", "[type='date']", "[type='month']", |
| 446 | + "[type='week']", "[type='time']", "[type='datetime-local']", "[type='range']", "[type='color']", |
| 447 | + "[type='radio']", "[type='checkbox']", "[contenteditable]", "[type='button']" ]; |
| 448 | + var clickListeners = [ "select", "option", "[type='radio']", "[type='checkbox']" ]; |
444 | 449 | $( this.currentForm )
|
445 |
| - .on( "focusin.validate focusout.validate keyup.validate", |
446 |
| - ":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " + |
447 |
| - "[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " + |
448 |
| - "[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " + |
449 |
| - "[type='radio'], [type='checkbox'], [contenteditable], [type='button']", delegate ) |
| 450 | + .on( "focusin.validate focusout.validate keyup.validate", focusListeners.concat( this.settings.customElements ).join( ", " ), delegate ) |
450 | 451 |
|
451 | 452 | // Support: Chrome, oldIE
|
452 | 453 | // "select" is provided as event.target when clicking a option
|
453 |
| - .on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate ); |
| 454 | + .on( "click.validate", clickListeners.concat( this.settings.customElements ).join( ", " ), delegate ); |
454 | 455 |
|
455 | 456 | if ( this.settings.invalidHandler ) {
|
456 | 457 | $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler );
|
@@ -647,11 +648,12 @@ $.extend( $.validator, {
|
647 | 648 |
|
648 | 649 | elements: function() {
|
649 | 650 | var validator = this,
|
650 |
| - rulesCache = {}; |
| 651 | + rulesCache = {}, |
| 652 | + selectors = [ "input", "select", "textarea", "[contenteditable]" ]; |
651 | 653 |
|
652 | 654 | // Select all valid inputs inside the form (no submit or reset buttons)
|
653 | 655 | return $( this.currentForm )
|
654 |
| - .find( "input, select, textarea, [contenteditable]" ) |
| 656 | + .find( selectors.concat( this.settings.customElements ).join( ", " ) ) |
655 | 657 | .not( ":submit, :reset, :image, :disabled" )
|
656 | 658 | .not( this.settings.ignore )
|
657 | 659 | .filter( function() {
|
@@ -1501,7 +1503,7 @@ $.extend( $.validator, {
|
1501 | 1503 |
|
1502 | 1504 | // https://jqueryvalidation.org/number-method/
|
1503 | 1505 | number: function( value, element ) {
|
1504 |
| - return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value ); |
| 1506 | + return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:-?\.\d+)?$/.test( value ); |
1505 | 1507 | },
|
1506 | 1508 |
|
1507 | 1509 | // https://jqueryvalidation.org/digits-method/
|
@@ -1612,11 +1614,12 @@ $.extend( $.validator, {
|
1612 | 1614 |
|
1613 | 1615 | param = typeof param === "string" && { url: param } || param;
|
1614 | 1616 | optionDataString = $.param( $.extend( { data: value }, param.data ) );
|
1615 |
| - if ( previous.old === optionDataString ) { |
| 1617 | + if ( previous.valid !== null && previous.old === optionDataString ) { |
1616 | 1618 | return previous.valid;
|
1617 | 1619 | }
|
1618 | 1620 |
|
1619 | 1621 | previous.old = optionDataString;
|
| 1622 | + previous.valid = null; |
1620 | 1623 | validator = this;
|
1621 | 1624 | this.startRequest( element );
|
1622 | 1625 | data = {};
|
|
0 commit comments