Skip to content

Commit 0391c96

Browse files
committed
Roll back changes from jquery.validate.js
1 parent 2eb3c93 commit 0391c96

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

lib/web/jquery/jquery.validate.js

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*!
2-
* jQuery Validation Plugin v1.19.5
2+
* jQuery Validation Plugin v1.19.3
33
*
44
* https://jqueryvalidation.org/
55
*
6-
* Copyright (c) 2022 Jörn Zaefferer
6+
* Copyright (c) 2021 Jörn Zaefferer
77
* Released under the MIT license
88
*/
99
(function( factory ) {
1010
if ( typeof define === "function" && define.amd ) {
11-
define( ["jquery"], factory );
11+
define( ["jquery", "jquery/jquery.metadata"], factory );
1212
} else if (typeof module === "object" && module.exports) {
1313
module.exports = factory( require( "jquery" ) );
1414
} else {
@@ -192,6 +192,7 @@
192192
data = $.validator.normalizeRules(
193193
$.extend(
194194
{},
195+
$.validator.metadataRules(element),
195196
$.validator.classRules( element ),
196197
$.validator.attributeRules( element ),
197198
$.validator.dataRules( element ),
@@ -377,6 +378,7 @@
377378
dateISO: "Please enter a valid date (ISO).",
378379
number: "Please enter a valid number.",
379380
digits: "Please enter only digits.",
381+
creditcard: "Please enter a valid credit card number.",
380382
equalTo: "Please enter the same value again.",
381383
maxlength: $.validator.format( "Please enter no more than {0} characters." ),
382384
minlength: $.validator.format( "Please enter at least {0} characters." ),
@@ -782,7 +784,7 @@
782784
normalizer = this.settings.normalizer;
783785
}
784786

785-
// If normalizer is defined, then call it to retreive the changed value instead
787+
// If normalizer is defined, then call it to retrieve the changed value instead
786788
// of using the real one.
787789
// Note that `this` in the normalizer is `element`.
788790
if ( normalizer ) {
@@ -873,13 +875,13 @@
873875
}
874876

875877
var message = this.findDefined(
876-
this.customMessage( element.name, rule.method ),
877-
this.customDataMessage( element, rule.method ),
878+
this.customMessage( element.name, rule.method ),
879+
this.customDataMessage( element, rule.method ),
878880

879-
// 'title' is never undefined, so handle empty string as undefined
880-
!this.settings.ignoreTitle && element.title || undefined,
881-
$.validator.messages[ rule.method ],
882-
"<strong>Warning: No message defined for " + element.name + "</strong>"
881+
// 'title' is never undefined, so handle empty string as undefined
882+
!this.settings.ignoreTitle && element.title || undefined,
883+
$.validator.messages[ rule.method ],
884+
"<strong>Warning: No message defined for " + element.name + "</strong>"
883885
),
884886
theregex = /\$?\{(\d+)\}/g;
885887
if ( typeof message === "function" ) {
@@ -980,7 +982,7 @@
980982
if ( this.labelContainer.length ) {
981983
this.labelContainer.append( place );
982984
} else if ( this.settings.errorPlacement ) {
983-
this.settings.errorPlacement.call( this, place, $( element ) );
985+
this.settings.errorPlacement( place, $( element ) );
984986
} else {
985987
place.insertAfter( element );
986988
}
@@ -1050,11 +1052,7 @@
10501052
// meta-characters that should be escaped in order to be used with JQuery
10511053
// as a literal part of a name/id or any selector.
10521054
escapeCssMeta: function( string ) {
1053-
if ( string === undefined ) {
1054-
return "";
1055-
}
1056-
1057-
return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" );
1055+
return (string || '').replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" );
10581056
},
10591057

10601058
idOrName: function( element ) {
@@ -1130,8 +1128,8 @@
11301128
}
11311129
delete this.pending[ element.name ];
11321130
$( element ).removeClass( this.settings.pendingClass );
1133-
if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() && this.pendingRequest === 0 ) {
1134-
$( this.currentForm ).trigger( "submit" );
1131+
if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
1132+
$( this.currentForm ).submit();
11351133

11361134
// Remove the hidden input that was used as a replacement for the
11371135
// missing submit button. The hidden input is added by `handle()`
@@ -1236,7 +1234,7 @@
12361234

12371235
// Exception: the jquery validate 'range' method
12381236
// does not test for the html5 'range' type
1239-
rules[ type === "date" ? "dateISO" : method ] = true;
1237+
rules[ method ] = true;
12401238
}
12411239
},
12421240

@@ -1275,6 +1273,17 @@
12751273
return rules;
12761274
},
12771275

1276+
metadataRules: function (element) {
1277+
if (!$.metadata) {
1278+
return {};
1279+
}
1280+
1281+
var meta = $.data(element.form, 'validator').settings.meta;
1282+
return meta ?
1283+
$(element).metadata()[meta] :
1284+
$(element).metadata();
1285+
},
1286+
12781287
dataRules: function( element ) {
12791288
var rules = {},
12801289
$element = $( element ),
@@ -1434,7 +1443,7 @@
14341443
// https://gist.github.com/dperini/729294
14351444
// see also https://mathiasbynens.be/demo/url-regex
14361445
// modified to allow protocol-relative URLs
1437-
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
1446+
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
14381447
},
14391448

14401449
// https://jqueryvalidation.org/date-method/

0 commit comments

Comments
 (0)