|
1 | 1 | /*!
|
2 |
| - * jQuery Validation Plugin v1.19.5 |
| 2 | + * jQuery Validation Plugin v1.19.3 |
3 | 3 | *
|
4 | 4 | * https://jqueryvalidation.org/
|
5 | 5 | *
|
6 |
| - * Copyright (c) 2022 Jörn Zaefferer |
| 6 | + * Copyright (c) 2021 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"], factory ); |
| 11 | + define( ["jquery", "jquery/jquery.metadata"], 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), |
195 | 196 | $.validator.classRules( element ),
|
196 | 197 | $.validator.attributeRules( element ),
|
197 | 198 | $.validator.dataRules( element ),
|
|
377 | 378 | dateISO: "Please enter a valid date (ISO).",
|
378 | 379 | number: "Please enter a valid number.",
|
379 | 380 | digits: "Please enter only digits.",
|
| 381 | + creditcard: "Please enter a valid credit card number.", |
380 | 382 | equalTo: "Please enter the same value again.",
|
381 | 383 | maxlength: $.validator.format( "Please enter no more than {0} characters." ),
|
382 | 384 | minlength: $.validator.format( "Please enter at least {0} characters." ),
|
|
782 | 784 | normalizer = this.settings.normalizer;
|
783 | 785 | }
|
784 | 786 |
|
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 |
786 | 788 | // of using the real one.
|
787 | 789 | // Note that `this` in the normalizer is `element`.
|
788 | 790 | if ( normalizer ) {
|
|
873 | 875 | }
|
874 | 876 |
|
875 | 877 | 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 ), |
878 | 880 |
|
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>" |
883 | 885 | ),
|
884 | 886 | theregex = /\$?\{(\d+)\}/g;
|
885 | 887 | if ( typeof message === "function" ) {
|
|
980 | 982 | if ( this.labelContainer.length ) {
|
981 | 983 | this.labelContainer.append( place );
|
982 | 984 | } else if ( this.settings.errorPlacement ) {
|
983 |
| - this.settings.errorPlacement.call( this, place, $( element ) ); |
| 985 | + this.settings.errorPlacement( place, $( element ) ); |
984 | 986 | } else {
|
985 | 987 | place.insertAfter( element );
|
986 | 988 | }
|
|
1050 | 1052 | // meta-characters that should be escaped in order to be used with JQuery
|
1051 | 1053 | // as a literal part of a name/id or any selector.
|
1052 | 1054 | escapeCssMeta: function( string ) {
|
1053 |
| - if ( string === undefined ) { |
1054 |
| - return ""; |
1055 |
| - } |
1056 |
| - |
1057 |
| - return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); |
| 1055 | + return (string || '').replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); |
1058 | 1056 | },
|
1059 | 1057 |
|
1060 | 1058 | idOrName: function( element ) {
|
|
1130 | 1128 | }
|
1131 | 1129 | delete this.pending[ element.name ];
|
1132 | 1130 | $( 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(); |
1135 | 1133 |
|
1136 | 1134 | // Remove the hidden input that was used as a replacement for the
|
1137 | 1135 | // missing submit button. The hidden input is added by `handle()`
|
|
1236 | 1234 |
|
1237 | 1235 | // Exception: the jquery validate 'range' method
|
1238 | 1236 | // does not test for the html5 'range' type
|
1239 |
| - rules[ type === "date" ? "dateISO" : method ] = true; |
| 1237 | + rules[ method ] = true; |
1240 | 1238 | }
|
1241 | 1239 | },
|
1242 | 1240 |
|
|
1275 | 1273 | return rules;
|
1276 | 1274 | },
|
1277 | 1275 |
|
| 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 | + |
1278 | 1287 | dataRules: function( element ) {
|
1279 | 1288 | var rules = {},
|
1280 | 1289 | $element = $( element ),
|
|
1434 | 1443 | // https://gist.github.com/dperini/729294
|
1435 | 1444 | // see also https://mathiasbynens.be/demo/url-regex
|
1436 | 1445 | // 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 ); |
1438 | 1447 | },
|
1439 | 1448 |
|
1440 | 1449 | // https://jqueryvalidation.org/date-method/
|
|
0 commit comments