|
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 ) {
|
10 | 10 | if ( typeof define === "function" && define.amd ) {
|
11 |
| - define( ["jquery", "jquery/jquery.metadata"], factory ); |
| 11 | + define( ["jquery"], factory ); |
12 | 12 | } else if (typeof module === "object" && module.exports) {
|
13 | 13 | module.exports = factory( require( "jquery" ) );
|
14 | 14 | } else {
|
|
192 | 192 | data = $.validator.normalizeRules(
|
193 | 193 | $.extend(
|
194 | 194 | {},
|
195 |
| - $.validator.metadataRules(element), |
196 | 195 | $.validator.classRules( element ),
|
197 | 196 | $.validator.attributeRules( element ),
|
198 | 197 | $.validator.dataRules( element ),
|
|
294 | 293 | onsubmit: true,
|
295 | 294 | ignore: ":hidden",
|
296 | 295 | ignoreTitle: false,
|
| 296 | + customElements: [], |
297 | 297 | onfocusin: function( element ) {
|
298 | 298 | this.lastActive = element;
|
299 | 299 |
|
|
441 | 441 | settings[ eventType ].call( validator, this, event );
|
442 | 442 | }
|
443 | 443 | }
|
444 |
| - |
| 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']" ]; |
445 | 449 | $( 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 ) |
| 450 | + .on( "focusin.validate focusout.validate keyup.validate", focusListeners.concat( this.settings.customElements ).join( ", " ), delegate ) |
451 | 451 |
|
452 | 452 | // Support: Chrome, oldIE
|
453 | 453 | // "select" is provided as event.target when clicking a option
|
454 |
| - .on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate ); |
| 454 | + .on( "click.validate", clickListeners.concat( this.settings.customElements ).join( ", " ), delegate ); |
455 | 455 |
|
456 | 456 | if ( this.settings.invalidHandler ) {
|
457 | 457 | $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler );
|
|
648 | 648 |
|
649 | 649 | elements: function() {
|
650 | 650 | var validator = this,
|
651 |
| - rulesCache = {}; |
| 651 | + rulesCache = {}, |
| 652 | + selectors = [ "input", "select", "textarea", "[contenteditable]" ]; |
652 | 653 |
|
653 | 654 | // Select all valid inputs inside the form (no submit or reset buttons)
|
654 | 655 | return $( this.currentForm )
|
655 |
| - .find( "input, select, textarea, [contenteditable]" ) |
| 656 | + .find( selectors.concat( this.settings.customElements ).join( ", " ) ) |
656 | 657 | .not( ":submit, :reset, :image, :disabled" )
|
657 | 658 | .not( this.settings.ignore )
|
658 | 659 | .filter( function() {
|
|
786 | 787 | normalizer = this.settings.normalizer;
|
787 | 788 | }
|
788 | 789 |
|
789 |
| - // If normalizer is defined, then call it to the changed value instead |
| 790 | + // If normalizer is defined, then call it to retreive the changed value instead |
790 | 791 | // of using the real one.
|
791 | 792 | // Note that `this` in the normalizer is `element`.
|
792 | 793 | if ( normalizer ) {
|
|
1311 | 1312 | return rules;
|
1312 | 1313 | },
|
1313 | 1314 |
|
1314 |
| - metadataRules: function (element) { |
1315 |
| - if (!$.metadata) { |
1316 |
| - return {}; |
1317 |
| - } |
1318 |
| - |
1319 |
| - var meta = $.data(element.form, 'validator').settings.meta; |
1320 |
| - return meta ? |
1321 |
| - $(element).metadata()[meta] : |
1322 |
| - $(element).metadata(); |
1323 |
| - }, |
1324 |
| - |
1325 | 1315 | dataRules: function( element ) {
|
1326 | 1316 | var rules = {},
|
1327 | 1317 | $element = $( element ),
|
|
1513 | 1503 |
|
1514 | 1504 | // https://jqueryvalidation.org/number-method/
|
1515 | 1505 | number: function( value, element ) {
|
1516 |
| - 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 ); |
1517 | 1507 | },
|
1518 | 1508 |
|
1519 | 1509 | // https://jqueryvalidation.org/digits-method/
|
|
1624 | 1614 |
|
1625 | 1615 | param = typeof param === "string" && { url: param } || param;
|
1626 | 1616 | optionDataString = $.param( $.extend( { data: value }, param.data ) );
|
1627 |
| - if ( previous.old === optionDataString ) { |
| 1617 | + if ( previous.valid !== null && previous.old === optionDataString ) { |
1628 | 1618 | return previous.valid;
|
1629 | 1619 | }
|
1630 | 1620 |
|
1631 | 1621 | previous.old = optionDataString;
|
| 1622 | + previous.valid = null; |
1632 | 1623 | validator = this;
|
1633 | 1624 | this.startRequest( element );
|
1634 | 1625 | data = {};
|
|
0 commit comments