|
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 ) {
|
|
294 | 294 | onsubmit: true,
|
295 | 295 | ignore: ":hidden",
|
296 | 296 | ignoreTitle: false,
|
| 297 | + customElements: [], |
297 | 298 | onfocusin: function( element ) {
|
298 | 299 | this.lastActive = element;
|
299 | 300 |
|
|
441 | 442 | settings[ eventType ].call( validator, this, event );
|
442 | 443 | }
|
443 | 444 | }
|
444 |
| - |
| 445 | + var focusListeners = [ ":text", "[type='password']", "[type='file']", "select", "textarea", "[type='number']", "[type='search']", |
| 446 | + "[type='tel']", "[type='url']", "[type='email']", "[type='datetime']", "[type='date']", "[type='month']", |
| 447 | + "[type='week']", "[type='time']", "[type='datetime-local']", "[type='range']", "[type='color']", |
| 448 | + "[type='radio']", "[type='checkbox']", "[contenteditable]", "[type='button']" ]; |
| 449 | + var clickListeners = [ "select", "option", "[type='radio']", "[type='checkbox']" ]; |
445 | 450 | $( this.currentForm )
|
446 |
| - .on( "focusin.validate focusout.validate keyup.validate", |
447 |
| - ":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " + |
448 |
| - "[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " + |
449 |
| - "[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " + |
450 |
| - "[type='radio'], [type='checkbox'], [contenteditable], [type='button']", delegate ) |
| 451 | + .on( "focusin.validate focusout.validate keyup.validate", focusListeners.concat( this.settings.customElements ).join( ", " ), delegate ) |
451 | 452 |
|
452 | 453 | // Support: Chrome, oldIE
|
453 | 454 | // "select" is provided as event.target when clicking a option
|
454 |
| - .on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate ); |
| 455 | + .on( "click.validate", clickListeners.concat( this.settings.customElements ).join( ", " ), delegate ); |
455 | 456 |
|
456 | 457 | if ( this.settings.invalidHandler ) {
|
457 | 458 | $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler );
|
|
648 | 649 |
|
649 | 650 | elements: function() {
|
650 | 651 | var validator = this,
|
651 |
| - rulesCache = {}; |
| 652 | + rulesCache = {}, |
| 653 | + selectors = [ "input", "select", "textarea", "[contenteditable]" ]; |
652 | 654 |
|
653 | 655 | // Select all valid inputs inside the form (no submit or reset buttons)
|
654 | 656 | return $( this.currentForm )
|
655 |
| - .find( "input, select, textarea, [contenteditable]" ) |
| 657 | + .find( selectors.concat( this.settings.customElements ).join( ", " ) ) |
656 | 658 | .not( ":submit, :reset, :image, :disabled" )
|
657 | 659 | .not( this.settings.ignore )
|
658 | 660 | .filter( function() {
|
|
1310 | 1312 |
|
1311 | 1313 | return rules;
|
1312 | 1314 | },
|
1313 |
| - |
1314 | 1315 | metadataRules: function (element) {
|
1315 | 1316 | if (!$.metadata) {
|
1316 | 1317 | return {};
|
|
1321 | 1322 | $(element).metadata()[meta] :
|
1322 | 1323 | $(element).metadata();
|
1323 | 1324 | },
|
1324 |
| - |
1325 | 1325 | dataRules: function( element ) {
|
1326 | 1326 | var rules = {},
|
1327 | 1327 | $element = $( element ),
|
|
1513 | 1513 |
|
1514 | 1514 | // https://jqueryvalidation.org/number-method/
|
1515 | 1515 | number: function( value, element ) {
|
1516 |
| - return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value ); |
| 1516 | + return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:-?\.\d+)?$/.test( value ); |
1517 | 1517 | },
|
1518 | 1518 |
|
1519 | 1519 | // https://jqueryvalidation.org/digits-method/
|
|
1624 | 1624 |
|
1625 | 1625 | param = typeof param === "string" && { url: param } || param;
|
1626 | 1626 | optionDataString = $.param( $.extend( { data: value }, param.data ) );
|
1627 |
| - if ( previous.old === optionDataString ) { |
| 1627 | + if ( previous.valid !== null && previous.old === optionDataString ) { |
1628 | 1628 | return previous.valid;
|
1629 | 1629 | }
|
1630 | 1630 |
|
1631 | 1631 | previous.old = optionDataString;
|
| 1632 | + previous.valid = null; |
1632 | 1633 | validator = this;
|
1633 | 1634 | this.startRequest( element );
|
1634 | 1635 | data = {};
|
|
0 commit comments