From d3ac892ba06287a484e7115957b087c4408fac9b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 29 Jul 2017 09:17:50 +0200 Subject: [PATCH 001/100] Build: Update release instructions --- build/release.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build/release.js b/build/release.js index ee16a1f8e..820600828 100644 --- a/build/release.js +++ b/build/release.js @@ -1,5 +1,6 @@ /* Release checklist - Run `git changelog` and edit to match previous output (this should make use of jquey-release instead) +- make sure the correct 'x.y.z-pre' version is defined in package.json - pull latest https://github.com/jquery/jquery-release - disable _generateChangelog task in release.js (BOOOO) - run From 365453a6c87848e6bc3f8cfdbbf5cfae923449de Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 29 Jul 2017 09:23:08 +0200 Subject: [PATCH 002/100] Build: Updating the master version to 1.17.1-pre. --- changelog.md | 42 ++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index ac7073c8e..cc7be908b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,45 @@ +1.17.0 / 2017-07-20 +================== + +## Core + * Pass on the value of the used submit button for scripted submits (#2019) + * Removed aria-required attribute (#2012) + * Assign rules to contenteditable via `.validate()` and `.rules()` (#1947) + * Count invalid fields with empty message in `numberOfInvalids()` (#1942) + * Added support for button elements with descendants (#1901) + * Add support for defining a global normalizer (#1905) + +## Additional + * Add localized number validation to methods_nl.js (#2014) + * Remove unreachable return from `cifES.js` (#1994) + * Add optional support to cifES, nifES and nieES (#1966) + * Add netmask validation method (#1955) + * Add Polish tax id validation method (#1850) + * Fixed validation for specific case for Spanish NIFs (#1914) + +## Localization + * Added Step Range Validation to messages_ja (#1936) + * Add hungarian step message (#1888) + * Add Sindhi locale (#1900) + * Added norsk step translation (#1918) + * Add missing french step translation (#1928) + * Added nl- translation for "step" property (#1902) + * Add French translation for notEqualTo method (#2033) + +## Readme + * Add note about trimming whitespaces inside required method (#2028) + +## Tests + * Pass on the value of the used submit button for scripted submits (#2019) + * Use assert#pushResult instead of assert#push (#2018) + +## All + * Fix links after move to organization + * Use https + +## Build + * Upgrade QUnit to 2.3.3 (#2018) + 1.16.0 / 2016-12-01 ================== diff --git a/package.json b/package.json index 6f7bf898e..47dc9e037 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.17.0-pre", + "version": "1.17.1-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From 5a721e86b20182a600e56c053dac58a4d7c1a5b0 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 29 Jul 2017 09:29:58 +0200 Subject: [PATCH 003/100] Build: updated release instructions --- build/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release.js b/build/release.js index 820600828..855611a54 100644 --- a/build/release.js +++ b/build/release.js @@ -8,7 +8,7 @@ - Wait a while, verify and confirm each step - Create GitHub release: Pick the new tag, add changelog, upload zip - Upload to NPM - git fetch --tags jzaefferer + git fetch --tags jquery-validation git checkout tags/X.YY.Z npm publish - Update MS CDN (Ping Chris Sfanos) From cac8f05e6b508b8e012d0a4f9c3774408c686728 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sat, 2 Sep 2017 12:42:09 +0100 Subject: [PATCH 004/100] Core: Allow the normalizer to return any value Fixes #2049 --- src/core.js | 4 ---- test/rules.js | 20 ++++++-------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/core.js b/src/core.js index e9d17db86..7eec1dc37 100644 --- a/src/core.js +++ b/src/core.js @@ -745,10 +745,6 @@ $.extend( $.validator, { if ( normalizer ) { val = normalizer.call( element, val ); - if ( typeof val !== "string" ) { - throw new TypeError( "The normalizer should return a string value." ); - } - // Delete the normalizer from rules to avoid treating it as a pre-defined method. delete rules.normalizer; } diff --git a/test/rules.js b/test/rules.js index 233c7f520..cfd9f8577 100644 --- a/test/rules.js +++ b/test/rules.js @@ -360,14 +360,11 @@ QUnit.test( "rules(), global/local normalizer", function( assert ) { }, lastname: { required: true, - normalizer: function( value ) { + normalizer: function() { assert.equal( this, lastname[ 0 ], "`this` in the normalizer should be the lastname element." ); - // Return null in order to make sure an exception is thrown - // when normalizer returns a non string value. - value = null; - - return value; + // The normalizer can return any value + return null; } } } @@ -388,15 +385,10 @@ QUnit.test( "rules(), global/local normalizer", function( assert ) { username.trigger( "keyup" ); urlc.trigger( "keyup" ); - assert.equal( v.numberOfInvalids(), 0, "All elements are valid" ); - assert.equal( v.size(), 0, "All elements are valid" ); + lastname.valid(); - // Validate the lastname element, which will throw an exception - assert.throws( function() { - v.check( lastname[ 0 ] ); - }, function( err ) { - return err.name === "TypeError" && err.message === "The normalizer should return a string value."; - }, "This should throw a TypeError exception." ); + assert.equal( v.numberOfInvalids(), 1, "Only one element is invalid" ); + assert.equal( v.size(), 1, "Only one element is invalid" ); } ); QUnit.test( "rules() - on unexpected input", function( assert ) { From 18b8497db4c59b6a55554b2cc6337afaadde15ec Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sat, 2 Sep 2017 16:53:45 +0100 Subject: [PATCH 005/100] Test: required method should return false for null & undefined values --- test/rules.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/rules.js b/test/rules.js index cfd9f8577..1be57bf49 100644 --- a/test/rules.js +++ b/test/rules.js @@ -402,3 +402,23 @@ QUnit.test( "rules() - on unexpected input", function( assert ) { result = nonFormElement.rules( "add", "whatever" ); assert.deepEqual( result, undefined, "can work on a non-form element" ); } ); + +QUnit.test( "required method should return false for undefined & null values", function( assert ) { + var username = $( "#usernamec" ), + urlc = $( "#urlc" ), + v = $( "#testForm1clean" ).validate( { + rules: { + username: { + required: true, + normalizer: function() { return null; } + }, + urlc: { + required: true, + normalizer: function() { return undefined; } + } + } + } ); + + assert.notOk( v.element( username ), "The username element should be invalid" ); + assert.notOk( v.element( urlc ), "The urlc element should be invalid" ); +} ); From b7bb3c27b67cff82e99a6af2a057f20d8d141c02 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sat, 2 Sep 2017 16:59:31 +0100 Subject: [PATCH 006/100] Core: guard against null & undefined values in required method An input element will never have undefined or null as value but the normalizer may return null or undefined for an element. Also, jQuery (< 3.x) returns `null` for select element with the multiple attribute set if no options are selected. As a result, the required method should guard against that. --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 7eec1dc37..11c57a027 100644 --- a/src/core.js +++ b/src/core.js @@ -1349,7 +1349,7 @@ $.extend( $.validator, { if ( this.checkable( element ) ) { return this.getLength( value, element ) > 0; } - return value.length > 0; + return value !== undefined && value !== null && value.length > 0; }, // https://jqueryvalidation.org/email-method/ From 5482dfd95ff01bb89a4fe5171f67c63d90c12198 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sat, 2 Sep 2017 18:52:03 +0100 Subject: [PATCH 007/100] Test: Add missing description to a test (#2055) --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index edc87563a..1ee1d5308 100644 --- a/test/test.js +++ b/test/test.js @@ -1039,7 +1039,7 @@ QUnit.test( "elementValue() returns the file input's name without the prefix 'C: assert.ok( !v.element( fileInput ), "The fake file input is invalid (length = 12, maxlength = 10)" ); } ); -QUnit.test( "", function( assert ) { +QUnit.test( "Required rule should not take precedence over number & digits rules", function( assert ) { var v = $( "#userForm" ).validate(), // A fake number input From 33f896a5ab061a913b6220559097305eb03a5d97 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 3 Sep 2017 15:42:02 +0100 Subject: [PATCH 008/100] Build: Include minified version of additional methods in npm package Fixes #2056 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 47dc9e037..b95061195 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "files": [ "dist/localization/", "dist/additional-methods.js", + "dist/additional-methods.min.js", "dist/jquery.validate.js", "dist/jquery.validate.min.js" ], From 539fa4d1426ed3d6ab6955865040660c56d3205e Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Mon, 4 Sep 2017 13:13:45 +0100 Subject: [PATCH 009/100] Build: Include localization files in tagged releases --- build/release.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/release.js b/build/release.js index 855611a54..1041c7951 100644 --- a/build/release.js +++ b/build/release.js @@ -36,7 +36,9 @@ Release.define({ generateArtifacts: function( done ) { Release.exec( "grunt release", "Grunt command failed" ); + // Keep this list of files in sync with package.json's files key done([ + "dist/localization/", "dist/additional-methods.js", "dist/additional-methods.min.js", "dist/jquery.validate.js", From fa73b79b1d714356bbf365b77110b8c4af7e8491 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 12 Sep 2017 15:58:14 +0200 Subject: [PATCH 010/100] Localization: Add Swedish validation message for remote (#2066) Fixes #2064 --- src/localization/messages_sv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/localization/messages_sv.js b/src/localization/messages_sv.js index 31d45f2aa..327bdd762 100644 --- a/src/localization/messages_sv.js +++ b/src/localization/messages_sv.js @@ -4,6 +4,7 @@ */ $.extend( $.validator.messages, { required: "Detta fält är obligatoriskt.", + remote: "Var snäll och åtgärda detta fält.", maxlength: $.validator.format( "Du får ange högst {0} tecken." ), minlength: $.validator.format( "Du måste ange minst {0} tecken." ), rangelength: $.validator.format( "Ange minst {0} och max {1} tecken." ), From a6725c386619588d77a3e1dafb14879232d9406b Mon Sep 17 00:00:00 2001 From: Hawkon Date: Wed, 13 Sep 2017 19:53:00 +0200 Subject: [PATCH 011/100] Localization: Add new danish translations (#2067) This update the danish translate and include new translates too. New translate: - pattern - nowhitespace - lettersonly - maxWords - minWords - notEqualTo - integer - extension - IPv4 - IPv6 - require_from_group - step - time - remote --- src/localization/messages_da.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/localization/messages_da.js b/src/localization/messages_da.js index b43673a99..4c0efcc1b 100644 --- a/src/localization/messages_da.js +++ b/src/localization/messages_da.js @@ -4,17 +4,31 @@ */ $.extend( $.validator.messages, { required: "Dette felt er påkrævet.", - maxlength: $.validator.format( "Indtast højst {0} tegn." ), - minlength: $.validator.format( "Indtast mindst {0} tegn." ), - rangelength: $.validator.format( "Indtast mindst {0} og højst {1} tegn." ), + remote: "Ret venligst dette felt", email: "Indtast en gyldig email-adresse.", url: "Indtast en gyldig URL.", date: "Indtast en gyldig dato.", number: "Indtast et tal.", digits: "Indtast kun cifre.", + creditcard: "Indtast et gyldigt kreditkortnummer.", equalTo: "Indtast den samme værdi igen.", + time: "Angiv en gyldig tid mellem kl. 00:00 og 23:59.", + ipv4: "Angiv venligst en gyldig IPv4-adresse.", + ipv6: "Angiv venligst en gyldig IPv6-adresse.", + require_from_group: $.validator.format( "Angiv mindst {0} af disse felter." ), + extension: "Indtast venligst en værdi med en gyldig endelse", + pattern: "Ugyldigt format", + lettersonly: "Angiv venligst kun bogstaver.", + nowhitespace: "Må ikke indholde mellemrum", + maxlength: $.validator.format( "Indtast højst {0} tegn." ), + minlength: $.validator.format( "Indtast mindst {0} tegn." ), + rangelength: $.validator.format( "Indtast mindst {0} og højst {1} tegn." ), range: $.validator.format( "Angiv en værdi mellem {0} og {1}." ), max: $.validator.format( "Angiv en værdi der højst er {0}." ), min: $.validator.format( "Angiv en værdi der mindst er {0}." ), - creditcard: "Indtast et gyldigt kreditkortnummer." + minWords: $.validator.format( "Indtast venligst mindst {0} ord" ), + maxWords: $.validator.format( "Indtast venligst højst {0} ord" ), + step: $.validator.format( "Angiv en værdi gange {0}." ), + notEqualTo: "Angiv en anden værdi, værdierne må ikke være det samme.", + integer: "Angiv et ikke-decimaltal, der er positivt eller negativt." } ); From c62e0d91bcf05bcda22e5cfa4068fcf6d4a21f2b Mon Sep 17 00:00:00 2001 From: Kevin Mian Kraiker Date: Sat, 16 Sep 2017 05:43:20 -0300 Subject: [PATCH 012/100] Localization: Fix typos in messages_pt_BR.js (#2073) --- src/localization/messages_pt_BR.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js index 015fad078..9e310e14f 100644 --- a/src/localization/messages_pt_BR.js +++ b/src/localization/messages_pt_BR.js @@ -22,7 +22,7 @@ $.extend( $.validator.messages, { range: $.validator.format( "Por favor, forneça um valor entre {0} e {1}." ), max: $.validator.format( "Por favor, forneça um valor menor ou igual a {0}." ), min: $.validator.format( "Por favor, forneça um valor maior ou igual a {0}." ), - step: $.validator.format( "Por favor, forneça um valor m´tiplo de {0}." ), + step: $.validator.format( "Por favor, forneça um valor m´ltiplo de {0}." ), // Metodos Adicionais maxWords: $.validator.format( "Por favor, forneça com {0} palavras ou menos." ), @@ -52,25 +52,25 @@ $.extend( $.validator.messages, { nieES: "Por favor, forneça um NIE válido.", nifES: "Por favor, forneça um NIF válido.", nowhitespace: "Por favor, não utilize espaços em branco.", - pattern: "O formato fornenecido é inválido.", - phoneNL: "Por favor, forneceça um número de telefone válido.", - phoneUK: "Por favor, forneceça um número de telefone válido.", - phoneUS: "Por favor, forneceça um número de telefone válido.", - phonesUK: "Por favor, forneceça um número de telefone válido.", - postalCodeCA: "Por favor, forneceça um número de código postal válido.", - postalcodeIT: "Por favor, forneceça um número de código postal válido.", - postalcodeNL: "Por favor, forneceça um número de código postal válido.", - postcodeUK: "Por favor, forneceça um número de código postal válido.", + pattern: "O formato fornecido é inválido.", + phoneNL: "Por favor, forneça um número de telefone válido.", + phoneUK: "Por favor, forneça um número de telefone válido.", + phoneUS: "Por favor, forneça um número de telefone válido.", + phonesUK: "Por favor, forneça um número de telefone válido.", + postalCodeCA: "Por favor, forneça um número de código postal válido.", + postalcodeIT: "Por favor, forneça um número de código postal válido.", + postalcodeNL: "Por favor, forneça um número de código postal válido.", + postcodeUK: "Por favor, forneça um número de código postal válido.", postalcodeBR: "Por favor, forneça um CEP válido.", require_from_group: $.validator.format( "Por favor, forneça pelo menos {0} destes campos." ), skip_or_fill_minimum: $.validator.format( "Por favor, optar entre ignorar esses campos ou preencher pelo menos {0} deles." ), stateUS: "Por favor, forneça um estado válido.", strippedminlength: $.validator.format( "Por favor, forneça pelo menos {0} caracteres." ), - time: "Por favor, forneça um horário válido, no intervado de 00:00 e 23:59.", - time12h: "Por favor, forneça um horário válido, no intervado de 01:00 e 12:59 am/pm.", - url2: "Por favor, forneceça uma URL válida.", - vinUS: "O número de identificação de veículo informada (VIN) é inválido.", - zipcodeUS: "Por favor, forneceça um código postal americano válido.", + time: "Por favor, forneça um horário válido, no intervado de 00:00 a 23:59.", + time12h: "Por favor, forneça um horário válido, no intervado de 01:00 a 12:59 am/pm.", + url2: "Por favor, forneça uma URL válida.", + vinUS: "O número de identificação de veículo informado (VIN) é inválido.", + zipcodeUS: "Por favor, forneça um código postal americano válido.", ziprange: "O código postal deve estar entre 902xx-xxxx e 905xx-xxxx", cpfBR: "Por favor, forneça um CPF válido." } ); From 3abd20f9fccc980d904e8b1a2f1edcf277f41c8c Mon Sep 17 00:00:00 2001 From: Rob Johnston Date: Tue, 19 Sep 2017 04:52:47 -0400 Subject: [PATCH 013/100] Localization: Add missing format method (#2075) Closes #2065 --- src/localization/messages_fr.js | 2 +- src/localization/messages_tr.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/localization/messages_fr.js b/src/localization/messages_fr.js index b588dfbad..0f804632a 100644 --- a/src/localization/messages_fr.js +++ b/src/localization/messages_fr.js @@ -43,7 +43,7 @@ $.extend( $.validator.messages, { creditcardtypes: "Veuillez fournir un numéro de carte de crédit valide.", ipv4: "Veuillez fournir une adresse IP v4 valide.", ipv6: "Veuillez fournir une adresse IP v6 valide.", - require_from_group: "Veuillez fournir au moins {0} de ces champs.", + require_from_group: $.validator.format( "Veuillez fournir au moins {0} de ces champs." ), nifES: "Veuillez fournir un numéro NIF valide.", nieES: "Veuillez fournir un numéro NIE valide.", cifES: "Veuillez fournir un numéro CIF valide.", diff --git a/src/localization/messages_tr.js b/src/localization/messages_tr.js index db2211303..1ca35e22c 100644 --- a/src/localization/messages_tr.js +++ b/src/localization/messages_tr.js @@ -20,5 +20,5 @@ $.extend( $.validator.messages, { range: $.validator.format( "Lütfen {0} ile {1} arasında bir değer giriniz." ), max: $.validator.format( "Lütfen {0} değerine eşit ya da daha küçük bir değer giriniz." ), min: $.validator.format( "Lütfen {0} değerine eşit ya da daha büyük bir değer giriniz." ), - require_from_group: "Lütfen bu alanların en az {0} tanesini doldurunuz." + require_from_group: $.validator.format( "Lütfen bu alanların en az {0} tanesini doldurunuz." ) } ); From 38cb9b9c8c135d9737d56f4a19ee48ca9a2d888b Mon Sep 17 00:00:00 2001 From: Rob Johnston Date: Tue, 19 Sep 2017 17:21:26 -0400 Subject: [PATCH 014/100] Additional: Add greaterThan and lessThan methods. (#2061) * Tests: Add tests for integers. * Core: Unbind the event and remove the class name. * Test: Test binding of blur event. * Test: Test binding of blur event. --- src/additional/greaterThan.js | 11 ++++++++ src/additional/greaterThanEqual.js | 11 ++++++++ src/additional/lessThan.js | 11 ++++++++ src/additional/lessThanEqual.js | 11 ++++++++ src/core.js | 14 ++++++++++- test/index.html | 6 ++++- test/methods.js | 40 ++++++++++++++++++++++++++++++ test/test.js | 13 +++++++++- 8 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 src/additional/greaterThan.js create mode 100644 src/additional/greaterThanEqual.js create mode 100644 src/additional/lessThan.js create mode 100644 src/additional/lessThanEqual.js diff --git a/src/additional/greaterThan.js b/src/additional/greaterThan.js new file mode 100644 index 000000000..67d8c3050 --- /dev/null +++ b/src/additional/greaterThan.js @@ -0,0 +1,11 @@ +$.validator.addMethod( "greaterThan", function( value, element, param ) { + var target = $( param ); + + if ( this.settings.onfocusout && target.not( ".validate-greaterThan-blur" ).length ) { + target.addClass( "validate-greaterThan-blur" ).on( "blur.validate-greaterThan", function() { + $( element ).valid(); + } ); + } + + return value > target.val(); +}, "Please enter a greater value." ); diff --git a/src/additional/greaterThanEqual.js b/src/additional/greaterThanEqual.js new file mode 100644 index 000000000..de6203728 --- /dev/null +++ b/src/additional/greaterThanEqual.js @@ -0,0 +1,11 @@ +$.validator.addMethod( "greaterThanEqual", function( value, element, param ) { + var target = $( param ); + + if ( this.settings.onfocusout && target.not( ".validate-greaterThanEqual-blur" ).length ) { + target.addClass( "validate-greaterThanEqual-blur" ).on( "blur.validate-greaterThanEqual", function() { + $( element ).valid(); + } ); + } + + return value >= target.val(); +}, "Please enter a greater value." ); diff --git a/src/additional/lessThan.js b/src/additional/lessThan.js new file mode 100644 index 000000000..2959bc362 --- /dev/null +++ b/src/additional/lessThan.js @@ -0,0 +1,11 @@ +$.validator.addMethod( "lessThan", function( value, element, param ) { + var target = $( param ); + + if ( this.settings.onfocusout && target.not( ".validate-lessThan-blur" ).length ) { + target.addClass( "validate-lessThan-blur" ).on( "blur.validate-lessThan", function() { + $( element ).valid(); + } ); + } + + return value < target.val(); +}, "Please enter a lesser value." ); diff --git a/src/additional/lessThanEqual.js b/src/additional/lessThanEqual.js new file mode 100644 index 000000000..78a1e25a6 --- /dev/null +++ b/src/additional/lessThanEqual.js @@ -0,0 +1,11 @@ +$.validator.addMethod( "lessThanEqual", function( value, element, param ) { + var target = $( param ); + + if ( this.settings.onfocusout && target.not( ".validate-lessThanEqual-blur" ).length ) { + target.addClass( "validate-lessThanEqual-blur" ).on( "blur.validate-lessThanEqual", function() { + $( element ).valid(); + } ); + } + + return value <= target.val(); +}, "Please enter a lesser value." ); diff --git a/src/core.js b/src/core.js index 11c57a027..f2d986118 100644 --- a/src/core.js +++ b/src/core.js @@ -1120,7 +1120,19 @@ $.extend( $.validator, { .removeData( "validator" ) .find( ".validate-equalTo-blur" ) .off( ".validate-equalTo" ) - .removeClass( "validate-equalTo-blur" ); + .removeClass( "validate-equalTo-blur" ) + .find( ".validate-lessThan-blur" ) + .off( ".validate-lessThan" ) + .removeClass( "validate-lessThan-blur" ) + .find( ".validate-lessThanEqual-blur" ) + .off( ".validate-lessThanEqual" ) + .removeClass( "validate-lessThanEqual-blur" ) + .find( ".validate-greaterThanEqual-blur" ) + .off( ".validate-greaterThanEqual" ) + .removeClass( "validate-greaterThanEqual-blur" ) + .find( ".validate-greaterThan-blur" ) + .off( ".validate-greaterThan" ) + .removeClass( "validate-greaterThan-blur" ); } }, diff --git a/test/index.html b/test/index.html index b0bf9bd3d..3235689da 100644 --- a/test/index.html +++ b/test/index.html @@ -109,7 +109,11 @@

-
+ + + + +
diff --git a/test/methods.js b/test/methods.js index 812a8b270..173a2281d 100644 --- a/test/methods.js +++ b/test/methods.js @@ -379,6 +379,26 @@ QUnit.test( "#1760 - step modulo/remainder regression tests", function( assert ) } } ); +QUnit.test( "lessThan", function( assert ) { + var v = jQuery( "#form" ).validate(), + method = $.validator.methods.lessThan, + e = $( "#value2" ); + + assert.ok( method.call( v, "1", e[ 0 ], "#value2" ), "Valid integer" ); + assert.ok( !method.call( v, "10", e[ 0 ], "#value2" ), "Invalid integer" ); + assert.ok( !method.call( v, "11", e[ 0 ], "#value2" ), "Invalid integer" ); +} ); + +QUnit.test( "lessThanEqual", function( assert ) { + var v = jQuery( "#form" ).validate(), + method = $.validator.methods.lessThanEqual, + e = $( "#value2" ); + + assert.ok( method.call( v, "1", e[ 0 ], "#value2" ), "Valid integer" ); + assert.ok( method.call( v, "10", e[ 0 ], "#value2" ), "Valid integer" ); + assert.ok( !method.call( v, "11", e[ 0 ], "#value2" ), "Invalid integer" ); +} ); + QUnit.test( "equalTo", function( assert ) { var v = jQuery( "#form" ).validate(), method = $.validator.methods.equalTo, @@ -388,6 +408,26 @@ QUnit.test( "equalTo", function( assert ) { assert.ok( method.call( v, "T", e[ 1 ], "#text2" ), "Another one" ); } ); +QUnit.test( "greaterThanEqual", function( assert ) { + var v = jQuery( "#form" ).validate(), + method = $.validator.methods.greaterThanEqual, + e = $( "#value2" ); + + assert.ok( !method.call( v, "1", e[ 0 ], "#value2" ), "Invalid integer" ); + assert.ok( method.call( v, "10", e[ 0 ], "#value2" ), "Valid integer" ); + assert.ok( method.call( v, "11", e[ 0 ], "#value2" ), "Valid integer" ); +} ); + +QUnit.test( "greaterThan", function( assert ) { + var v = jQuery( "#form" ).validate(), + method = $.validator.methods.greaterThan, + e = $( "#value2" ); + + assert.ok( !method.call( v, "1", e[ 0 ], "#value2" ), "Invalid integer" ); + assert.ok( !method.call( v, "10", e[ 0 ], "#value2" ), "Invalid integer" ); + assert.ok( method.call( v, "11", e[ 0 ], "#value2" ), "Valid integer" ); +} ); + QUnit.test( "extension", function( assert ) { var method = methodTest( "extension" ), v; diff --git a/test/test.js b/test/test.js index 1ee1d5308..79bf0cf1b 100644 --- a/test/test.js +++ b/test/test.js @@ -2440,7 +2440,7 @@ QUnit.test( "Validation triggered on radio and checkbox via click", function( as } ); QUnit.test( "destroy()", function( assert ) { - assert.expect( 6 ); + assert.expect( 14 ); var form = $( "#testForm5" ), validate = form.validate(); @@ -2451,10 +2451,21 @@ QUnit.test( "destroy()", function( assert ) { assert.equal( $( "#x1", form ).hasClass( "validate-equalTo-blur" ), true, "The blur event should be bound to this element" ); assert.equal( $( "#x2", form ).hasClass( "validate-equalTo-blur" ), true, "The blur event should be bound to this element" ); + assert.equal( $( "#y1", form ).hasClass( "validate-greaterThan-blur" ), true, "The blur event should be bound to this element" ); + assert.equal( $( "#y2", form ).hasClass( "validate-lessThan-blur" ), true, "The blur event should be bound to this element" ); + assert.equal( $( "#z1", form ).hasClass( "validate-greaterThanEqual-blur" ), true, "The blur event should be bound to this element" ); + assert.equal( $( "#z2", form ).hasClass( "validate-lessThanEqual-blur" ), true, "The blur event should be bound to this element" ); + validate.destroy(); assert.strictEqual( form.data( "validator" ), undefined ); assert.equal( $( "#x1", form ).hasClass( "validate-equalTo-blur" ), false, "The blur event should be unbound from this element" ); assert.equal( $( "#x2", form ).hasClass( "validate-equalTo-blur" ), false, "The blur event should be unbound from this element" ); + + assert.equal( $( "#y1", form ).hasClass( "validate-lessThan-blur" ), false, "The blur event should be unbound from this element" ); + assert.equal( $( "#y2", form ).hasClass( "validate-greaterThan-blur" ), false, "The blur event should be unbound from this element" ); + assert.equal( $( "#z1", form ).hasClass( "validate-equalTo-blur" ), false, "The blur event should be unbound from this element" ); + assert.equal( $( "#z2", form ).hasClass( "validate-greaterThan-blur" ), false, "The blur event should be unbound from this element" ); + } ); QUnit.test( "#1618: Errorlist containing more errors than it should", function( assert ) { From b70fcc20f1bcdcd63422686595a48950326309f1 Mon Sep 17 00:00:00 2001 From: Hawkon Date: Sat, 23 Sep 2017 19:30:37 +0200 Subject: [PATCH 015/100] Shield.io release badget (#2076) Added Shield.io release badget and a tab error in one of the code examples --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20e18c6ad..e734d9e20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [jQuery Validation Plugin](https://jqueryvalidation.org/) - Form validation made easy ================================ +[![release](https://img.shields.io/github/release/jquery-validation/jquery-validation.svg)](https://github.com/jquery-validation/jquery-validation/releases/latest) [![Build Status](https://secure.travis-ci.org/jquery-validation/jquery-validation.svg)](https://travis-ci.org/jquery-validation/jquery-validation) [![devDependency Status](https://david-dm.org/jquery-validation/jquery-validation/dev-status.svg?theme=shields.io)](https://david-dm.org/jquery-validation/jquery-validation#info=devDependencies) @@ -31,7 +32,7 @@ Include jQuery and the plugin on a page. Then select a form to validate and call ``` From 2c615e7b9baac4c06e2934418b3d6766fd7fe78d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 4 Oct 2017 09:52:42 +0200 Subject: [PATCH 016/100] Localization: fixed wrong placeholder in vi translation Closes #2085 --- src/localization/messages_vi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localization/messages_vi.js b/src/localization/messages_vi.js index fda8ef17e..f639ec855 100644 --- a/src/localization/messages_vi.js +++ b/src/localization/messages_vi.js @@ -19,5 +19,5 @@ $.extend( $.validator.messages, { rangelength: $.validator.format( "Hãy nhập từ {0} đến {1} kí tự." ), range: $.validator.format( "Hãy nhập từ {0} đến {1}." ), max: $.validator.format( "Hãy nhập từ {0} trở xuống." ), - min: $.validator.format( "Hãy nhập từ {1} trở lên." ) + min: $.validator.format( "Hãy nhập từ {0} trở lên." ) } ); From 7e9e4788bfe290800cbdf1a8d2a147cd396ca031 Mon Sep 17 00:00:00 2001 From: Rob Johnston Date: Sun, 8 Oct 2017 16:25:24 -0400 Subject: [PATCH 017/100] Additional: max size and number of files (#2087) This commit contains: * Validate max number and size of file(s). * Add tests for max number and size of file(s). --- src/additional/maxfiles.js | 14 +++++ src/additional/maxsize.js | 18 ++++++ src/additional/maxsizetotal.js | 22 +++++++ test/methods.js | 111 +++++++++++++++++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 src/additional/maxfiles.js create mode 100644 src/additional/maxsize.js create mode 100644 src/additional/maxsizetotal.js diff --git a/src/additional/maxfiles.js b/src/additional/maxfiles.js new file mode 100644 index 000000000..0cf53e735 --- /dev/null +++ b/src/additional/maxfiles.js @@ -0,0 +1,14 @@ +// Limit the number of files in a FileList. +$.validator.addMethod( "maxfiles", function( value, element, param ) { + if ( this.optional( element ) ) { + return true; + } + + if ( $( element ).attr( "type" ) === "file" ) { + if ( element.files && element.files.length > param ) { + return false; + } + } + + return true; +}, $.validator.format( "Please select no more than {0} files." ) ); diff --git a/src/additional/maxsize.js b/src/additional/maxsize.js new file mode 100644 index 000000000..0b9db7cd3 --- /dev/null +++ b/src/additional/maxsize.js @@ -0,0 +1,18 @@ +// Limit the size of each individual file in a FileList. +$.validator.addMethod( "maxsize", function( value, element, param ) { + if ( this.optional( element ) ) { + return true; + } + + if ( $( element ).attr( "type" ) === "file" ) { + if ( element.files && element.files.length ) { + for ( var i = 0; i < element.files.length; i++ ) { + if ( element.files[ i ].size > param ) { + return false; + } + } + } + } + + return true; +}, $.validator.format( "File size must not exceed {0} bytes each." ) ); diff --git a/src/additional/maxsizetotal.js b/src/additional/maxsizetotal.js new file mode 100644 index 000000000..c2f990bca --- /dev/null +++ b/src/additional/maxsizetotal.js @@ -0,0 +1,22 @@ +// Limit the size of all files in a FileList. +$.validator.addMethod( "maxsizetotal", function( value, element, param ) { + if ( this.optional( element ) ) { + return true; + } + + if ( $( element ).attr( "type" ) === "file" ) { + if ( element.files && element.files.length ) { + var totalSize = 0; + + for ( var i = 0; i < element.files.length; i++ ) { + totalSize += element.files[ i ].size; + if ( totalSize > param ) { + return false; + } + } + } + } + + return true; +}, $.validator.format( "Total size of all files must not exceed {0} bytes." ) ); + diff --git a/test/methods.js b/test/methods.js index 173a2281d..ce36e896f 100644 --- a/test/methods.js +++ b/test/methods.js @@ -42,6 +42,39 @@ function acceptFileDummyInput( filename, mimeType ) { }; } +function fileDummyInput( selectedFiles ) { + var aFiles = [], + oFiles; + + for ( var i = 0; i < selectedFiles.length; i++ ) { + aFiles.push( { + name: selectedFiles[ i ].name, + size: selectedFiles[ i ].size, + type: "image/jpeg" + } ); + } + + //Convert the array of objects to an object. + oFiles = aFiles.reduce( function( acc, cur, i ) { + acc[ i ] = cur; + return acc; + }, {} ); + + //Add the "length" property to the object. + oFiles.length = selectedFiles.length; + + //Add the "item()" method to the object. + oFiles.item = function( i ) { return aFiles[ i ]; }; + + return { + type: "file", + files: oFiles, + nodeName: "INPUT", + value: "/tmp/fake_value", + hasAttribute: function() { return false; } + }; +} + QUnit.module( "methods" ); QUnit.test( "default messages", function( assert ) { @@ -1704,3 +1737,81 @@ QUnit.test( "file accept - invalid mime type", function( assert ) { proxy = $.proxy( $.validator.methods.accept, new $.validator( {}, $form[ 0 ] ), null, input, "application/vnd.google-earth.kml+xml" ); assert.equal( proxy(), false, "the selected file for upload has invalid mime type" ); } ); + +QUnit.test( "file size - below max", function( assert ) { + var input = acceptFileDummyInput( "test.png", "image/png" ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, "500001" ); + assert.ok( proxy(), "the selected file for upload is smaller than max" ); +} ); + +QUnit.test( "file size - over max", function( assert ) { + var input = acceptFileDummyInput( "test.png", "image/png" ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, "500000" ); + assert.equal( proxy(), false, "the selected file for upload is greater than max" ); +} ); + +QUnit.test( "file maxsize - valid size", function( assert ) { + var selectedFiles = [ { name: "test.jpg", size: 500000 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.ok( proxy(), "the size of the file does not exceed the maximum" ); +} ); + +QUnit.test( "file maxsize - valid size for each file", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 500000 }, { name: "test2.jpg", size: 500000 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.ok( proxy(), "the size of the each file does not exceed the maximum" ); +} ); + +QUnit.test( "file maxsize - too big", function( assert ) { + var selectedFiles = [ { name: "test.jpg", size: 500001 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.equal( proxy(), false, "the size of the file exceeds the maximum" ); +} ); + +QUnit.test( "file maxsize - second file too big", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 500000 }, { name: "test2.jpg", size: 500001 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsize, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.equal( proxy(), false, "the size of the second file exceeds the maximum" ); +} ); + +QUnit.test( "file maxsizetotal - valid size", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 250000 }, { name: "test2.jpg", size: 250000 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsizetotal, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.ok( proxy(), "the size of the files together does not exceed the maximum" ); +} ); + +QUnit.test( "file maxsizetotal - too big", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 250000 }, { name: "test2.jpg", size: 250001 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxsizetotal, new $.validator( {}, $form[ 0 ] ), null, input, 500000 ); + assert.equal( proxy(), false, "the size of the files together exceeds the maximum" ); +} ); + +QUnit.test( "file maxfiles - valid number", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 500000 }, { name: "test2.jpg", size: 500000 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxfiles, new $.validator( {}, $form[ 0 ] ), null, input, 2 ); + assert.ok( proxy(), "the number of files does not exceed the maximum" ); +} ); + +QUnit.test( "file maxfiles - too many", function( assert ) { + var selectedFiles = [ { name: "test1.jpg", size: 500000 }, { name: "test2.jpg", size: 500000 }, { name: "test3.jpg", size: 500000 } ], + input = fileDummyInput( selectedFiles ), + $form = $( "" ), + proxy = $.proxy( $.validator.methods.maxfiles, new $.validator( {}, $form[ 0 ] ), null, input, 2 ); + assert.equal( proxy(), false, "the number of files exceeds the maximum" ); +} ); From 5ecd6c261fbf5fedb170654f0d37a335155ebca0 Mon Sep 17 00:00:00 2001 From: Rob Johnston Date: Mon, 9 Oct 2017 08:46:58 -0400 Subject: [PATCH 018/100] Additional: Add new BIN range for MasterCard. (#2088) Fixes #1904 --- src/additional/creditcardtypes.js | 2 +- test/methods.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/additional/creditcardtypes.js b/src/additional/creditcardtypes.js index 2a61e6a7a..6b9285be7 100644 --- a/src/additional/creditcardtypes.js +++ b/src/additional/creditcardtypes.js @@ -38,7 +38,7 @@ $.validator.addMethod( "creditcardtypes", function( value, element, param ) { if ( param.all ) { validTypes = 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040 | 0x0080; } - if ( validTypes & 0x0001 && /^(5[12345])/.test( value ) ) { // Mastercard + if ( validTypes & 0x0001 && ( /^(5[12345])/.test( value ) || /^(2[234567])/.test( value ) ) ) { // Mastercard return value.length === 16; } if ( validTypes & 0x0002 && /^(4)/.test( value ) ) { // Visa diff --git a/test/methods.js b/test/methods.js index ce36e896f..c9556f74b 100644 --- a/test/methods.js +++ b/test/methods.js @@ -1236,6 +1236,7 @@ QUnit.test( "creditcardtypes, all", function( assert ) { } ); testCardTypeByNumber( assert, "4111-1111-1111-1111", "VISA", true ); + testCardTypeByNumber( assert, "2211-1111-1111-1114", "MasterCard", true ); testCardTypeByNumber( assert, "5111-1111-1111-1118", "MasterCard", true ); testCardTypeByNumber( assert, "6111-1111-1111-1116", "Discover", true ); testCardTypeByNumber( assert, "3400-0000-0000-009", "AMEX", true ); @@ -1276,6 +1277,7 @@ QUnit.test( "creditcardtypes, mastercard", function( assert ) { } } ); + testCardTypeByNumber( assert, "2211-1111-1111-1114", "MasterCard", true ); testCardTypeByNumber( assert, "5111-1111-1111-1118", "MasterCard", true ); testCardTypeByNumber( assert, "6111-1111-1111-1116", "Discover", false ); testCardTypeByNumber( assert, "3400-0000-0000-009", "AMEX", false ); From f08c170bdf4f4cd9c38b3405a3d64f8b3de7c002 Mon Sep 17 00:00:00 2001 From: Lukas Drgon Date: Mon, 9 Oct 2017 19:07:27 +0200 Subject: [PATCH 019/100] Readme: Add jsDelivr hits badge (#2090) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e734d9e20..f02786c1c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![release](https://img.shields.io/github/release/jquery-validation/jquery-validation.svg)](https://github.com/jquery-validation/jquery-validation/releases/latest) [![Build Status](https://secure.travis-ci.org/jquery-validation/jquery-validation.svg)](https://travis-ci.org/jquery-validation/jquery-validation) [![devDependency Status](https://david-dm.org/jquery-validation/jquery-validation/dev-status.svg?theme=shields.io)](https://david-dm.org/jquery-validation/jquery-validation#info=devDependencies) +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/jquery-validation/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery-validation) The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy. From 1c3352e7a7190d8d0e8598cd95dc282fef83c38e Mon Sep 17 00:00:00 2001 From: Samuel Lie Date: Sat, 4 Nov 2017 12:38:50 +0100 Subject: [PATCH 020/100] Localization: Add remote translation to no (#2097) --- src/localization/messages_no.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/localization/messages_no.js b/src/localization/messages_no.js index 748efe8f1..c0f4338e5 100644 --- a/src/localization/messages_no.js +++ b/src/localization/messages_no.js @@ -4,6 +4,7 @@ */ $.extend( $.validator.messages, { required: "Dette feltet er obligatorisk.", + remote: "Vennligst angi og ordne verdien i feltet.", maxlength: $.validator.format( "Maksimalt {0} tegn." ), minlength: $.validator.format( "Minimum {0} tegn." ), rangelength: $.validator.format( "Angi minimum {0} og maksimum {1} tegn." ), From ec32afa2bd7652690f298b7631411778777da055 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Fri, 1 Dec 2017 10:46:16 +0200 Subject: [PATCH 021/100] Localization: fix meaning in Bulgarian sentence (#2112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "maxlength" message has wrong meaning in Bulgarian. The current meaning is: Please enter more than {0} characters. The correct meaning should be: Please enter no more than {0} characters. I could use "less" (по-малко) to mean the same thing, but it does not sound natural in this context. --- src/localization/messages_bg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localization/messages_bg.js b/src/localization/messages_bg.js index 141465695..f92c6f073 100644 --- a/src/localization/messages_bg.js +++ b/src/localization/messages_bg.js @@ -14,7 +14,7 @@ $.extend( $.validator.messages, { creditcard: "Моля, въведете валиден номер на кредитна карта.", equalTo: "Моля, въведете същата стойност отново.", extension: "Моля, въведете стойност с валидно разширение.", - maxlength: $.validator.format( "Моля, въведете повече от {0} символа." ), + maxlength: $.validator.format( "Моля, въведете не повече от {0} символа." ), minlength: $.validator.format( "Моля, въведете поне {0} символа." ), rangelength: $.validator.format( "Моля, въведете стойност с дължина между {0} и {1} символа." ), range: $.validator.format( "Моля, въведете стойност между {0} и {1}." ), From d66c318f2a1195aded4226473e045c4ff8a87111 Mon Sep 17 00:00:00 2001 From: Caro Caserio Date: Sat, 2 Dec 2017 11:46:23 -0300 Subject: [PATCH 022/100] README: Fixed wording --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e6181cf2..d317b2ab7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ Thanks for contributing! Here's a few guidelines to help your contribution get l ## Build setup 1. Install [NodeJS](http://nodejs.org). -2. Install the Grunt CLI To install by running `npm install -g grunt-cli`. More details are available on their website http://gruntjs.com/getting-started. +2. Install the Grunt CLI by running `npm install -g grunt-cli`. More details are available on their website http://gruntjs.com/getting-started. 3. Install the NPM dependencies by running `npm install`. 4. The build can now be called by running `grunt`. From 6ff4a02a131925032df83305013e3a5b6a364a8e Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 4 Dec 2017 16:46:25 +0100 Subject: [PATCH 023/100] Localization: Update German language file (#2115) --- src/localization/messages_de.js | 58 ++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/localization/messages_de.js b/src/localization/messages_de.js index dff7c964c..bf68e6667 100644 --- a/src/localization/messages_de.js +++ b/src/localization/messages_de.js @@ -7,14 +7,64 @@ $.extend( $.validator.messages, { maxlength: $.validator.format( "Geben Sie bitte maximal {0} Zeichen ein." ), minlength: $.validator.format( "Geben Sie bitte mindestens {0} Zeichen ein." ), rangelength: $.validator.format( "Geben Sie bitte mindestens {0} und maximal {1} Zeichen ein." ), - email: "Geben Sie bitte eine gültige E-Mail Adresse ein.", + email: "Geben Sie bitte eine gültige E-Mail-Adresse ein.", url: "Geben Sie bitte eine gültige URL ein.", - date: "Bitte geben Sie ein gültiges Datum ein.", + date: "Geben Sie bitte ein gültiges Datum ein.", number: "Geben Sie bitte eine Nummer ein.", digits: "Geben Sie bitte nur Ziffern ein.", - equalTo: "Bitte denselben Wert wiederholen.", + equalTo: "Wiederholen Sie bitte denselben Wert.", range: $.validator.format( "Geben Sie bitte einen Wert zwischen {0} und {1} ein." ), max: $.validator.format( "Geben Sie bitte einen Wert kleiner oder gleich {0} ein." ), min: $.validator.format( "Geben Sie bitte einen Wert größer oder gleich {0} ein." ), - creditcard: "Geben Sie bitte eine gültige Kreditkarten-Nummer ein." + creditcard: "Geben Sie bitte eine gültige Kreditkarten-Nummer ein.", + remote: "Korrigieren Sie bitte dieses Feld.", + dateISO: "Geben Sie bitte ein gültiges Datum ein (ISO-Format).", + step: $.validator.format( "Geben Sie bitte ein Vielfaches von {0} ein." ), + maxWords: $.validator.format( "Geben Sie bitte {0} Wörter oder weniger ein." ), + minWords: $.validator.format( "Geben Sie bitte mindestens {0} Wörter ein." ), + rangeWords: $.validator.format( "Geben Sie bitte zwischen {0} und {1} Wörtern ein." ), + accept: "Geben Sie bitte einen Wert mit einem gültigen MIME-Typ ein.", + alphanumeric: "Geben Sie bitte nur Buchstaben (keine Umlaute), Zahlen oder Unterstriche ein.", + bankaccountNL: "Geben Sie bitte eine gültige Kontonummer ein.", + bankorgiroaccountNL: "Geben Sie bitte eine gültige Bank- oder Girokontonummer ein.", + bic: "Geben Sie bitte einen gültigen BIC-Code ein.", + cifES: "Geben Sie bitte eine gültige CIF-Nummer ein.", + cpfBR: "Geben Sie bitte eine gültige CPF-Nummer ein.", + creditcardtypes: "Geben Sie bitte eine gültige Kreditkarten-Nummer ein.", + currency: "Geben Sie bitte eine gültige Währung ein.", + extension: "Geben Sie bitte einen Wert mit einer gültigen Erweiterung ein.", + giroaccountNL: "Geben Sie bitte eine gültige Girokontonummer ein.", + iban: "Geben Sie bitte eine gültige IBAN ein.", + integer: "Geben Sie bitte eine positive oder negative Nicht-Dezimalzahl ein.", + ipv4: "Geben Sie bitte eine gültige IPv4-Adresse ein.", + ipv6: "Geben Sie bitte eine gültige IPv6-Adresse ein.", + lettersonly: "Geben Sie bitte nur Buchstaben ein.", + letterswithbasicpunc: "Geben Sie bitte nur Buchstaben oder Interpunktion ein.", + mobileNL: "Geben Sie bitte eine gültige Handynummer ein.", + mobileUK: "Geben Sie bitte eine gültige Handynummer ein.", + netmask: "Geben Sie bitte eine gültige Netzmaske ein.", + nieES: "Geben Sie bitte eine gültige NIE-Nummer ein.", + nifES: "Geben Sie bitte eine gültige NIF-Nummer ein.", + nipPL: "Geben Sie bitte eine gültige NIP-Nummer ein.", + notEqualTo: "Geben Sie bitte einen anderen Wert ein. Die Werte dürfen nicht gleich sein.", + nowhitespace: "Kein Leerzeichen bitte.", + pattern: "Ungültiges Format.", + phoneNL: "Geben Sie bitte eine gültige Telefonnummer ein.", + phonesUK: "Geben Sie bitte eine gültige britische Telefonnummer ein.", + phoneUK: "Geben Sie bitte eine gültige Telefonnummer ein.", + phoneUS: "Geben Sie bitte eine gültige Telefonnummer ein.", + postalcodeBR: "Geben Sie bitte eine gültige brasilianische Postleitzahl ein.", + postalCodeCA: "Geben Sie bitte eine gültige kanadische Postleitzahl ein.", + postalcodeIT: "Geben Sie bitte eine gültige italienische Postleitzahl ein.", + postalcodeNL: "Geben Sie bitte eine gültige niederländische Postleitzahl ein.", + postcodeUK: "Geben Sie bitte eine gültige britische Postleitzahl ein.", + require_from_group: $.validator.format( "Füllen Sie bitte mindestens {0} dieser Felder aus." ), + skip_or_fill_minimum: $.validator.format( "Überspringen Sie bitte diese Felder oder füllen Sie mindestens {0} von ihnen aus." ), + stateUS: "Geben Sie bitte einen gültigen US-Bundesstaat ein.", + strippedminlength: $.validator.format( "Geben Sie bitte mindestens {0} Zeichen ein." ), + time: "Geben Sie bitte eine gültige Uhrzeit zwischen 00:00 und 23:59 ein.", + time12h: "Geben Sie bitte eine gültige Uhrzeit im 12-Stunden-Format ein.", + vinUS: "Die angegebene Fahrzeugidentifikationsnummer (VIN) ist ungültig.", + zipcodeUS: "Die angegebene US-Postleitzahl ist ungültig.", + ziprange: "Ihre Postleitzahl muss im Bereich 902xx-xxxx bis 905xx-xxxx liegen." } ); From d4541614ec2748efbebb5c4a74fb15fe543ac8ab Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 15 Dec 2017 10:19:10 +0100 Subject: [PATCH 024/100] Additional: Updated link to EAN docs (#2120) --- src/additional/creditcard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/additional/creditcard.js b/src/additional/creditcard.js index bb0159b62..d2953d3e8 100644 --- a/src/additional/creditcard.js +++ b/src/additional/creditcard.js @@ -18,7 +18,7 @@ $.validator.addMethod( "creditcard", function( value, element ) { value = value.replace( /\D/g, "" ); // Basing min and max length on - // https://developer.ean.com/general_info/Valid_Credit_Card_Types + // https://dev.ean.com/general-info/valid-card-types/ if ( value.length < 13 || value.length > 19 ) { return false; } From e35d5f6625bfd0a101eeb3d0a3aa82019406e5e6 Mon Sep 17 00:00:00 2001 From: Siamak Mokhtari Date: Mon, 18 Dec 2017 00:49:44 +0330 Subject: [PATCH 025/100] Localization: Update messages_fa.js (#2122) --- src/localization/messages_fa.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/localization/messages_fa.js b/src/localization/messages_fa.js index edd643084..234687bd7 100644 --- a/src/localization/messages_fa.js +++ b/src/localization/messages_fa.js @@ -5,16 +5,17 @@ $.extend( $.validator.messages, { required: "تکمیل این فیلد اجباری است.", remote: "لطفا این فیلد را تصحیح کنید.", - email: ".لطفا یک ایمیل صحیح وارد کنید", + email: "لطفا یک ایمیل صحیح وارد کنید.", url: "لطفا آدرس صحیح وارد کنید.", - date: "لطفا یک تاریخ صحیح وارد کنید", - dateFA: "لطفا یک تاریخ صحیح وارد کنید", + date: "لطفا تاریخ صحیح وارد کنید.", + dateFA: "لطفا یک تاریخ صحیح وارد کنید.", dateISO: "لطفا تاریخ صحیح وارد کنید (ISO).", number: "لطفا عدد صحیح وارد کنید.", - digits: "لطفا تنها رقم وارد کنید", + digits: "لطفا تنها رقم وارد کنید.", creditcard: "لطفا کریدیت کارت صحیح وارد کنید.", - equalTo: "لطفا مقدار برابری وارد کنید", - extension: "لطفا مقداری وارد کنید که ", + equalTo: "لطفا مقدار برابری وارد کنید.", + extension: "لطفا مقداری وارد کنید که", + alphanumeric: "لطفا مقدار را عدد (انگلیسی) وارد کنید.", maxlength: $.validator.format( "لطفا بیشتر از {0} حرف وارد نکنید." ), minlength: $.validator.format( "لطفا کمتر از {0} حرف وارد نکنید." ), rangelength: $.validator.format( "لطفا مقداری بین {0} تا {1} حرف وارد کنید." ), From 1f4d69f6dca1e4f789326e3480743cf43fda5079 Mon Sep 17 00:00:00 2001 From: George Gooding Date: Mon, 29 Jan 2018 18:23:19 +0100 Subject: [PATCH 026/100] Localization: Update messages_no.js (#2132) Cleaning up and simplifying Norwegian translations, removing Swedish non-standard translations for validators not included in project source code. --- src/localization/messages_no.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/localization/messages_no.js b/src/localization/messages_no.js index c0f4338e5..cd47c6cdc 100644 --- a/src/localization/messages_no.js +++ b/src/localization/messages_no.js @@ -3,20 +3,18 @@ * Locale: NO (Norwegian; Norsk) */ $.extend( $.validator.messages, { - required: "Dette feltet er obligatorisk.", - remote: "Vennligst angi og ordne verdien i feltet.", - maxlength: $.validator.format( "Maksimalt {0} tegn." ), - minlength: $.validator.format( "Minimum {0} tegn." ), - rangelength: $.validator.format( "Angi minimum {0} og maksimum {1} tegn." ), - email: "Oppgi en gyldig epostadresse.", + required: "Angi en verdi.", + remote: "Ugyldig verdi.", + email: "Angi en gyldig epostadresse.", url: "Angi en gyldig URL.", date: "Angi en gyldig dato.", dateISO: "Angi en gyldig dato (&ARING;&ARING;&ARING;&ARING;-MM-DD).", - dateSE: "Angi en gyldig dato.", - number: "Angi et gyldig nummer.", - numberSE: "Angi et gyldig nummer.", + number: "Angi et gyldig tall.", digits: "Skriv kun tall.", equalTo: "Skriv samme verdi igjen.", + maxlength: $.validator.format( "Maksimalt {0} tegn." ), + minlength: $.validator.format( "Minimum {0} tegn." ), + rangelength: $.validator.format( "Angi minimum {0} og maksimum {1} tegn." ), range: $.validator.format( "Angi en verdi mellom {0} og {1}." ), max: $.validator.format( "Angi en verdi som er mindre eller lik {0}." ), min: $.validator.format( "Angi en verdi som er større eller lik {0}." ), From 4d9e485dc5dd5ea5b454b78b9462382c4741fcab Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Mon, 29 Jan 2018 21:20:52 +0000 Subject: [PATCH 027/100] Build: test on node 6.x and drop node 0.12.x (#2133) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 57665d998..e328e33da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 0.12 + - 6 sudo: false From 5651c37f01594c59b9291220b5127f08c42cf4be Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 1 Feb 2018 10:18:59 +0100 Subject: [PATCH 028/100] Additional: Add validation method for Polish telephone number --- src/additional/phonePL.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/additional/phonePL.js diff --git a/src/additional/phonePL.js b/src/additional/phonePL.js new file mode 100644 index 000000000..66846412f --- /dev/null +++ b/src/additional/phonePL.js @@ -0,0 +1,23 @@ +/** + * Polish telephone numbers have 9 digits. + * + * Mobile phone numbers starts with following digits: + * 45, 50, 51, 53, 57, 60, 66, 69, 72, 73, 78, 79, 88. + * + * Fixed-line numbers starts with area codes: + * 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 29, 32, 33, + * 34, 41, 42, 43, 44, 46, 48, 52, 54, 55, 56, 58, 59, 61, + * 62, 63, 65, 67, 68, 71, 74, 75, 76, 77, 81, 82, 83, 84, + * 85, 86, 87, 89, 91, 94, 95. + * + * Ministry of National numbers Defence and VoIP numbers starts with 26 and 39. + * + * Excludes intelligent networks (premium rate, shared cost, free phone numbers). + * + * Poland National Numbering Plan http://www.itu.int/oth/T02020000A8/en + */ +$.validator.addMethod( "phonePL", function( phone_number, element ) { + phone_number = phone_number.replace( /\s+/g, "" ); + var regexp = /^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/; + return this.optional( element ) || regexp.test( phone_number ); +}, "Please specify a valid phone number" ); From cfbd480b4f6773a754194b013f5577ccf618b27d Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 1 Feb 2018 10:25:02 +0100 Subject: [PATCH 029/100] Localization: Add message for phonePL method --- src/localization/messages_pl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/localization/messages_pl.js b/src/localization/messages_pl.js index a9dff5585..1f77009ec 100644 --- a/src/localization/messages_pl.js +++ b/src/localization/messages_pl.js @@ -15,6 +15,7 @@ $.extend( $.validator.messages, { equalTo: "Proszę o podanie tej samej wartości ponownie.", extension: "Proszę o podanie wartości z prawidłowym rozszerzeniem.", nipPL: "Proszę o podanie prawidłowego numeru NIP.", + phonePL: "Proszę o podanie prawidłowego numeru telefonu", maxlength: $.validator.format( "Proszę o podanie nie więcej niż {0} znaków." ), minlength: $.validator.format( "Proszę o podanie przynajmniej {0} znaków." ), rangelength: $.validator.format( "Proszę o podanie wartości o długości od {0} do {1} znaków." ), From de806ce0f0fde9b95d3a4917034243cc656f84cf Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 1 Feb 2018 10:28:51 +0100 Subject: [PATCH 030/100] Test: Add tests for phonePL method --- test/methods.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/methods.js b/test/methods.js index c9556f74b..d27fab1f6 100644 --- a/test/methods.js +++ b/test/methods.js @@ -1598,6 +1598,24 @@ QUnit.test( "nipPL", function( assert ) { assert.ok( !method( "9502947712" ), "NIP invalid: wrong checksum" ); } ); +QUnit.test( "phonePL", function( assert ) { + var method = methodTest( "phonePL" ); + assert.ok( method( "+48 123 456 789" ), "Valid phone PL" ); + assert.ok( method( "00 48 123 456 789" ), "Valid phone PL" ); + assert.ok( method( "(+48) 123 456 789" ), "Valid phone PL" ); + assert.ok( method( "(48) 123 456 789" ), "Valid phone PL" ); + assert.ok( method( " 13 34 56 78 9 " ), "Valid phone PL" ); + assert.ok( method( "13 345 67 89" ), "Valid phone PL" ); + assert.ok( !method( "100 000 000" ), "Invalid phone PL: cannot start with 10x xxx xxx" ); + assert.ok( !method( "111 111 111" ), "Invalid phone PL: cannot start with 11x xxx xxx" ); + assert.ok( !method( "123 456 78" ), "Invalid phone PL: too short" ); + assert.ok( !method( "123 4567890" ), "Invalid phone PL: too long" ); + assert.ok( !method( "700 123 456" ), "Invalid phone PL: intelligent network, premium rate" ); + assert.ok( !method( "800 123 456" ), "Invalid phone PL: intelligent network, freephone" ); + assert.ok( !method( "980 000 000" ), "Invalid phone PL: cannot start with 98x xxx xxx" ); + assert.ok( !method( "990 000 000" ), "Invalid phone PL: cannot start with 99x xxx xxx" ); +} ); + QUnit.test( "maxWords", function( assert ) { var method = methodTest( "maxWords" ), maxWords = 6; From 660a4777d427c8d41ce6492292bbf7d2f003a27a Mon Sep 17 00:00:00 2001 From: Lukasz Date: Fri, 9 Feb 2018 16:50:32 +0100 Subject: [PATCH 031/100] Additional: Fix typo --- src/additional/phonePL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/additional/phonePL.js b/src/additional/phonePL.js index 66846412f..cca314df4 100644 --- a/src/additional/phonePL.js +++ b/src/additional/phonePL.js @@ -10,7 +10,7 @@ * 62, 63, 65, 67, 68, 71, 74, 75, 76, 77, 81, 82, 83, 84, * 85, 86, 87, 89, 91, 94, 95. * - * Ministry of National numbers Defence and VoIP numbers starts with 26 and 39. + * Ministry of National Defence numbers and VoIP numbers starts with 26 and 39. * * Excludes intelligent networks (premium rate, shared cost, free phone numbers). * From fc25612ef02cc90cd577682ccf64bc21bb483dd5 Mon Sep 17 00:00:00 2001 From: Keith Morrison Date: Wed, 14 Feb 2018 00:04:06 -0800 Subject: [PATCH 032/100] Additional: allow N11 exchange for non-geo US phone. Fixes #1695 (#2098) --- src/additional/phoneUS.js | 2 +- test/methods.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/additional/phoneUS.js b/src/additional/phoneUS.js index fed8ac354..894a25c67 100644 --- a/src/additional/phoneUS.js +++ b/src/additional/phoneUS.js @@ -17,5 +17,5 @@ $.validator.addMethod( "phoneUS", function( phone_number, element ) { phone_number = phone_number.replace( /\s+/g, "" ); return this.optional( element ) || phone_number.length > 9 && - phone_number.match( /^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/ ); + phone_number.match( /^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/ ); }, "Please specify a valid phone number" ); diff --git a/test/methods.js b/test/methods.js index d27fab1f6..43f2ec0c1 100644 --- a/test/methods.js +++ b/test/methods.js @@ -814,9 +814,9 @@ QUnit.test( "phone (us)", function( assert ) { assert.ok( method( "1(212)-999-2345" ), "Valid US phone number" ); assert.ok( method( "212 999 2344" ), "Valid US phone number" ); assert.ok( method( "212-999-0983" ), "Valid US phone number" ); + assert.ok( method( "234-911-5678" ), "Valid US phone number" ); assert.ok( !method( "111-123-5434" ), "Invalid US phone number. Area Code cannot start with 1" ); assert.ok( !method( "212 123 4567" ), "Invalid US phone number. NXX cannot start with 1" ); - assert.ok( !method( "234-911-5678" ), "Invalid US phone number, because the exchange code cannot be in the form N11" ); assert.ok( !method( "911-333-5678" ), "Invalid US phone number, because the area code cannot be in the form N11" ); assert.ok( method( "234-912-5678" ), "Valid US phone number" ); } ); From a0bc9c45a9f16626da97aec506693524839dba29 Mon Sep 17 00:00:00 2001 From: Geraldo Ribeiro Date: Fri, 16 Feb 2018 05:11:38 -0200 Subject: [PATCH 033/100] Typo pt-BR (#2139) --- src/localization/messages_pt_BR.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js index 9e310e14f..504c3042c 100644 --- a/src/localization/messages_pt_BR.js +++ b/src/localization/messages_pt_BR.js @@ -22,7 +22,7 @@ $.extend( $.validator.messages, { range: $.validator.format( "Por favor, forneça um valor entre {0} e {1}." ), max: $.validator.format( "Por favor, forneça um valor menor ou igual a {0}." ), min: $.validator.format( "Por favor, forneça um valor maior ou igual a {0}." ), - step: $.validator.format( "Por favor, forneça um valor m´ltiplo de {0}." ), + step: $.validator.format( "Por favor, forneça um valor múltiplo de {0}." ), // Metodos Adicionais maxWords: $.validator.format( "Por favor, forneça com {0} palavras ou menos." ), From cd206d3f2be42f69f84ac62dda51a84567ae4057 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sat, 17 Feb 2018 09:29:29 +0000 Subject: [PATCH 034/100] Core: Add deprecation warning to 'date' method (#2138) Ref #1787 --- src/core.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core.js b/src/core.js index f2d986118..74d195e42 100644 --- a/src/core.js +++ b/src/core.js @@ -1385,9 +1385,26 @@ $.extend( $.validator, { }, // https://jqueryvalidation.org/date-method/ - date: function( value, element ) { - return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); - }, + date: ( function() { + var called = false; + + return function( value, element ) { + if ( !called ) { + called = true; + if ( this.settings.debug && window.console ) { + console.warn( + "The `date` method is deprecated and will be removed in version '2.0.0'.\n" + + "Please don't use it, since it relies on the Date constructor, which\n" + + "behaves very differently across browsers and locales. Use `dateISO`\n" + + "instead or one of the locale specific methods in `localizations/`\n" + + "and `additional-methods.js`." + ); + } + } + + return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); + }; + }() ), // https://jqueryvalidation.org/dateISO-method/ dateISO: function( value, element ) { From c8f8f7bb9bd7f74015fb75cdb425c60298136168 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 4 Mar 2018 13:33:01 +0000 Subject: [PATCH 035/100] Readme: Comment out irrelevant parts of issue and proposal templates --- .github/ISSUE_TEMPLATE.md | 16 ++++++++++------ .github/PULL_REQUEST_TEMPLATE.md | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5bac57838..478023c77 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,19 +1,23 @@ + ### Subject of the issue -Describe your issue here. + ### Your environment -* version of `jquery-validate` -* which browser and its version +* version of `jquery-validate`: +* which browser and its version: ### Steps to reproduce -Tell us how to reproduce this issue. If pssible, please provide a working demo in JSFiddle (https://jsfiddle.net) or JSBin (https://jsbin.com/). + ### Expected behaviour -Tell us what should happen + ### Actual behaviour -Tell us what happens instead + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 45afa2e04..d67f5b16e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,4 @@ + #### Description -Please describe your pull request. + Thank you! From 8769eab80e0ec83415c5ac434e7af3587641c34c Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 4 Mar 2018 01:17:47 +0000 Subject: [PATCH 036/100] Test: Ignore elements that belong to other/nested forms --- test/index.html | 5 +- test/test.js | 167 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 1 deletion(-) diff --git a/test/index.html b/test/index.html index 3235689da..0079aa7d9 100644 --- a/test/index.html +++ b/test/index.html @@ -113,7 +113,7 @@

- +
@@ -449,6 +449,9 @@


+
+ +
diff --git a/test/test.js b/test/test.js index 79bf0cf1b..dbe901556 100644 --- a/test/test.js +++ b/test/test.js @@ -187,6 +187,173 @@ QUnit.test( "valid(), ignores ignored elements", function( assert ) { assert.ok( $( "#firstnamec" ).valid() ); } ); +QUnit.test( "valid() should ignore elements that belong to other/nested forms", function( assert ) { + var form = $( "#testForm28" ); + + form.validate(); + + // 1. Test with nested form + form.append( + "
" + + " " + + "
" + ); + + try { + form.valid(); + assert.ok( true, "It should ignore the input of nested form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + // Remove the validator atteched to testForm28 + form.removeData( "validator" ); + $( "#testForm28-nested" ).remove(); + + // 2. Test using another form outside of validated one + form.parent().append( + "
" + + " " + + " " + + "
" + ); + + $( "#testForm28-other" ).validate(); + + try { + $( "#testForm28-other" ).valid(); + assert.ok( true, "It should ignore the input of other form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + $( "#testForm28-other" ).remove(); +} ); + +QUnit.test( "form() should ignore elements that belong to other/nested forms", function( assert ) { + var form = $( "#testForm28" ); + var v = form.validate(); + + form.validate(); + + // 1. Test with nested form + form.append( + "
" + + " " + + "
" + ); + + try { + v.form(); + assert.ok( true, "It should ignore the input of nested form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + // Remove the validator atteched to testForm28 + form.removeData( "validator" ); + $( "#testForm28-nested" ).remove(); + + // 2. Test using another form outside of validated one + form.parent().append( + "
" + + " " + + " " + + "
" + ); + + v = $( "#testForm28-other" ).validate(); + + try { + v.form(); + assert.ok( true, "It should ignore the input of other form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + $( "#testForm28-other" ).remove(); +} ); + +QUnit.test( "elements() should ignore elements that belong to other/nested forms", function( assert ) { + var form = $( "#testForm28" ); + var v = form.validate(); + + // 1. Test with nested form + form.append( + "
" + + " " + + "
" + ); + + try { + assert.equal( v.elements().length, 1, "There should be only one element to validate" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + // Remove the validator atteched to testForm28 + form.removeData( "validator" ); + $( "#testForm28-nested" ).remove(); + + // 2. Test using another form outside of validated one + form.parent().append( + "
" + + " " + + " " + + "
" + ); + + v = $( "#testForm28-other" ).validate(); + + try { + assert.equal( v.elements().length, 1, "There should be only one element to validate" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error" ); + } + + $( "#testForm28-other" ).remove(); +} ); + +QUnit.test( "Ignore elements that have form attribute set to other forms", function( assert ) { + + // Append a form that contains an input with form attribute set to "testForm28" + $( "#testForm28" ).parent().append( + "
" + + " " + + " " + + "
" + ); + + // Attach the plugin to the appended form + $( "#testForm28-other" ).validate(); + + // 1. Simulate typing + try { + $( "[name='f28input']", "#testForm28-other" ).trigger( "keyup" ); + assert.ok( true, "It should ignore the input of other form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error while typing" ); + } + + // 2. Simulate forcussing in the input + try { + $( "[name='f28input']", "#testForm28-other" ).trigger( "focusin" ); + assert.ok( true, "It should ignore the input of other form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error on focus" ); + } + + // 3. Simulate focussing out the input + try { + $( "[name='f28input']", "#testForm28-other" ).trigger( "focusout" ); + assert.ok( true, "It should ignore the input of other form" ); + } catch ( err ) { + assert.ok( false, "Shouldn't throw an error on blur" ); + } + + $( "#testForm28-other" ).remove(); +} ); + QUnit.test( "addMethod", function( assert ) { assert.expect( 3 ); $.validator.addMethod( "hi", function( value ) { From a355a0fe2970c92b801bf6d7621c6b90f412fa3d Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 4 Mar 2018 13:14:18 +0000 Subject: [PATCH 037/100] Core: Ignore elements that belong to other/nested forms Ref #704 Ref #1970 Fixes #2035 --- src/core.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 74d195e42..93fe25568 100644 --- a/src/core.js +++ b/src/core.js @@ -375,7 +375,8 @@ $.extend( $.validator, { this.invalid = {}; this.reset(); - var groups = ( this.groups = {} ), + var currentForm = this.currentForm, + groups = ( this.groups = {} ), rules; $.each( this.settings.groups, function( key, value ) { if ( typeof value === "string" ) { @@ -398,6 +399,12 @@ $.extend( $.validator, { this.name = $( this ).attr( "name" ); } + // Ignore the element if it belongs to another form. This will happen mainly + // when setting the `form` attribute of an input to the id of another form. + if ( currentForm !== this.form ) { + return; + } + var validator = $.data( this.form, "validator" ), eventType = "on" + event.type.replace( /^validate/, "" ), settings = validator.settings; @@ -631,6 +638,11 @@ $.extend( $.validator, { this.name = name; } + // Ignore elements that belong to other/nested forms + if ( this.form !== validator.currentForm ) { + return false; + } + // Select only the first element for each name, and only those with rules specified if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) { return false; From a3925cd2c38d41abfb9ec0f46c131050ed93c00b Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Tue, 29 May 2018 05:52:44 +0000 Subject: [PATCH 038/100] Build: Generate sub-resource integrity hashes of the distribution files (#2082) Fixes #2059 --- Gruntfile.js | 24 +++++++++++++++++++++++- build/release.js | 5 ++++- package.json | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a444d75c9..c5fe1df1e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -171,6 +171,27 @@ grunt.initConfig( { } ] } + }, + + // Generate the sub-resource integrity hashes of the distribution files + sri: { + options: { + algorithms: [ "sha256", "sha384", "sha512" ], + + // The target json file + dest: "dist/jquery-validation-sri.json", + + // Stringify the JSON output in a pretty format + pretty: true + }, + + all: { + src: [ + "dist/jquery.validate.{min.js,js}", + "dist/additional-methods.{min.js,js}", + "dist/localization/*.js" + ] + } } } ); @@ -183,9 +204,10 @@ grunt.loadNpmTasks( "grunt-contrib-watch" ); grunt.loadNpmTasks( "grunt-jscs" ); grunt.loadNpmTasks( "grunt-contrib-copy" ); grunt.loadNpmTasks( "grunt-text-replace" ); +grunt.loadNpmTasks( "grunt-sri" ); grunt.registerTask( "default", [ "concat", "copy", "jscs", "jshint", "qunit" ] ); -grunt.registerTask( "release", [ "default", "uglify", "replace", "compress" ] ); +grunt.registerTask( "release", [ "default", "uglify", "replace", "compress", "sri" ] ); grunt.registerTask( "start", [ "concat", "watch" ] ); }; diff --git a/build/release.js b/build/release.js index 1041c7951..7ba8a04fc 100644 --- a/build/release.js +++ b/build/release.js @@ -42,7 +42,10 @@ Release.define({ "dist/additional-methods.js", "dist/additional-methods.min.js", "dist/jquery.validate.js", - "dist/jquery.validate.min.js" + "dist/jquery.validate.min.js", + + // The sub-resource integrity hashes of the distribution files + "dist/jquery-validation-sri.json" ]); }, diff --git a/package.json b/package.json index b95061195..4b1e91017 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "grunt-contrib-uglify": "1.0.1", "grunt-contrib-watch": "1.0.0", "grunt-jscs": "2.8.0", + "grunt-sri": "0.2.0", "grunt-text-replace": "0.4.0", "qunitjs": "2.3.3" }, From b108ed1fb5c1c9cdaa3eb779527de397aa83c612 Mon Sep 17 00:00:00 2001 From: Yuan Xulei Date: Tue, 5 Jun 2018 20:20:03 +0800 Subject: [PATCH 039/100] localization: add step validation string to message_zh (#2177) --- src/localization/messages_zh.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/localization/messages_zh.js b/src/localization/messages_zh.js index 3d349f3c5..9c0d0c31d 100644 --- a/src/localization/messages_zh.js +++ b/src/localization/messages_zh.js @@ -18,6 +18,7 @@ $.extend( $.validator.messages, { minlength: $.validator.format( "最少要输入 {0} 个字符" ), rangelength: $.validator.format( "请输入长度在 {0} 到 {1} 之间的字符串" ), range: $.validator.format( "请输入范围在 {0} 到 {1} 之间的数值" ), + step: $.validator.format( "请输入 {0} 的整数倍值" ), max: $.validator.format( "请输入不大于 {0} 的数值" ), min: $.validator.format( "请输入不小于 {0} 的数值" ) } ); From 934822bb1ec52dac0c3de86010e0e69e4b4a2e0f Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Tue, 5 Jun 2018 12:32:26 +0000 Subject: [PATCH 040/100] All: Use Stale bot to manage stale issues (#2176) Ref #2127 --- .github/stale.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..d522d3d27 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,24 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 30 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - bug + - "help wanted" + - "MERGE ME" + - "NEEDS REVIEW" +# Ignore issues in a milestone +exemptMilestones: true +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue/proposal has been automatically marked as idle and stale because it hasn't + had any recent activity. It will be automtically closed if no further activity + occurs. If you think this is wrong, or the problem still persists, just pop + a reply in the comments and one of the maintainers will (try!) to follow up. + + Thank you for contributing :) +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false From bc5e651a360ed7fe194c5710a48d60badf854a77 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Tue, 19 Jun 2018 00:05:48 +0100 Subject: [PATCH 041/100] Test: Cast empty data attributes to 'true' --- test/index.html | 4 +++- test/rules.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/index.html b/test/index.html index 0079aa7d9..d02732856 100644 --- a/test/index.html +++ b/test/index.html @@ -277,7 +277,9 @@

- + + +
diff --git a/test/rules.js b/test/rules.js index 1be57bf49..178f810b2 100644 --- a/test/rules.js +++ b/test/rules.js @@ -157,7 +157,7 @@ QUnit.test( "rules(), class and attribute combinations", function( assert ) { $( "#v2" ).validate( { rules: { - "v2-i7": { + "v2-i9": { required: true, minlength: 2, customMethod: true @@ -173,8 +173,10 @@ QUnit.test( "rules(), class and attribute combinations", function( assert ) { jQuery.validator.autoCreateRanges = true; assert.deepEqual( $( "#v2-i5" ).rules(), { required: true, customMethod1: "123", rangelength: [ 2, 5 ] } ); assert.deepEqual( $( "#v2-i6" ).rules(), { required: true, customMethod2: true, rangelength: [ 2, 5 ] } ); + assert.deepEqual( $( "#v2-i7" ).rules(), { required: true, number: true } ); + assert.deepEqual( $( "#v2-i8" ).rules(), { required: true, number: true } ); jQuery.validator.autoCreateRanges = false; - assert.deepEqual( $( "#v2-i7" ).rules(), { required: true, minlength: 2, customMethod: true } ); + assert.deepEqual( $( "#v2-i9" ).rules(), { required: true, minlength: 2, customMethod: true } ); delete $.validator.methods.customMethod1; delete $.validator.messages.customMethod1; From b9a7a8d55c277468f71f5ee4607d2511497953a7 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Tue, 19 Jun 2018 00:09:34 +0100 Subject: [PATCH 042/100] Core: Cast empty data attributes to 'true' Fixes #1754 --- src/core.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core.js b/src/core.js index 93fe25568..b32519893 100644 --- a/src/core.js +++ b/src/core.js @@ -1248,6 +1248,12 @@ $.extend( $.validator, { for ( method in $.validator.methods ) { value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() ); + + // Cast empty attributes like `data-rule-required` to `true` + if ( value === "" ) { + value = true; + } + this.normalizeAttributeRule( rules, type, method, value ); } return rules; From 349fc57055f33f58dc3a141ab62cd9fec89cb3d3 Mon Sep 17 00:00:00 2001 From: George Henne Date: Wed, 20 Jun 2018 10:46:55 -0400 Subject: [PATCH 043/100] Demo: Add sample code for Bootstrap 4 usage (#2173) --- demo/bootstrap/index-bs4.html | 164 ++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 demo/bootstrap/index-bs4.html diff --git a/demo/bootstrap/index-bs4.html b/demo/bootstrap/index-bs4.html new file mode 100644 index 000000000..8c9afc7cc --- /dev/null +++ b/demo/bootstrap/index-bs4.html @@ -0,0 +1,164 @@ + + + + JQuery-validation demo | Bootstrap + + + + + + + +
+
+
+
+ +
+ +
+
+
Simple Form
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + + From e26547a01ee5ebb341e6a624da40870e338b75e2 Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Thu, 28 Jun 2018 07:33:36 +0100 Subject: [PATCH 044/100] All: Increase number of days of inactivity of stale issues to 60 days (#2186) --- .github/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/stale.yml b/.github/stale.yml index d522d3d27..c6fd0c20b 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,5 +1,5 @@ # Number of days of inactivity before an issue becomes stale -daysUntilStale: 30 +daysUntilStale: 60 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale From 2037129e004b45bb05975658aa7f19d580bf2d6e Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 29 Jul 2018 15:58:24 +0100 Subject: [PATCH 045/100] Core: Don't call submitHandler when in debug mode (#2193) Fixes #2042 --- src/core.js | 3 ++- test/methods.js | 6 ------ test/test.js | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/core.js b/src/core.js index b32519893..ac7e25763 100644 --- a/src/core.js +++ b/src/core.js @@ -49,6 +49,7 @@ $.extend( $.fn, { // Prevent form submit to be able to see console output event.preventDefault(); } + function handle() { var hidden, result; @@ -64,7 +65,7 @@ $.extend( $.fn, { .appendTo( validator.currentForm ); } - if ( validator.settings.submitHandler ) { + if ( validator.settings.submitHandler && !validator.settings.debug ) { result = validator.settings.submitHandler.call( validator, validator.currentForm, event ); if ( hidden ) { diff --git a/test/methods.js b/test/methods.js index 43f2ec0c1..db2d67169 100644 --- a/test/methods.js +++ b/test/methods.js @@ -500,9 +500,6 @@ QUnit.test( "remote", function( assert ) { required: "Please", remote: jQuery.validator.format( "{0} in use" ) } - }, - submitHandler: function() { - assert.ok( false, "submitHandler may never be called when validating only elements" ); } } ), done = assert.async(); @@ -595,9 +592,6 @@ QUnit.test( "remote extensions", function( assert ) { username: { required: "Please" } - }, - submitHandler: function() { - assert.ok( false, "submitHandler may never be called when validating only elements" ); } } ), done = assert.async(); diff --git a/test/test.js b/test/test.js index dbe901556..870d625d5 100644 --- a/test/test.js +++ b/test/test.js @@ -167,14 +167,10 @@ QUnit.test( "valid() ???", function( assert ) { v.errorList = errorList; assert.ok( !v.valid(), "One error, must be invalid" ); v.destroy(); - v = $( "#testForm3" ).validate( { - submitHandler: function() { - assert.ok( false, "Submit handler was called" ); - } - } ); - assert.ok( v.valid(), "No errors, must be valid and returning true, even with the submit handler" ); + v = $( "#testForm3" ).validate(); + assert.ok( v.valid(), "No errors, must be valid and returning true" ); v.errorList = errorList; - assert.ok( !v.valid(), "One error, must be invalid, no call to submit handler" ); + assert.ok( !v.valid(), "One error, must be invalid" ); } ); QUnit.test( "valid(), ignores ignored elements", function( assert ) { @@ -576,13 +572,14 @@ QUnit.test( "submitHandler keeps submitting button", function( assert ) { var button, event; $( "#userForm" ).validate( { - debug: true, + debug: false, submitHandler: function( form ) { - // Dunno how to test this better; this tests the implementation that uses a hidden input var hidden = $( form ).find( "input:hidden" )[ 0 ]; assert.deepEqual( hidden.value, button.value ); assert.deepEqual( hidden.name, button.name ); + + return false; } } ); $( "#username" ).val( "bla" ); @@ -596,7 +593,7 @@ QUnit.test( "submitHandler keeps submitting button", function( assert ) { QUnit.test( "submitHandler keeps submitting button, even if descendants are clicked", function( assert ) { var button = $( "#testForm27 :submit" )[ 0 ]; var v = $( "#testForm27" ).validate( { - debug: true, + debug: false, submitHandler: function( form ) { // Compare the button with the `submitButton` property @@ -1370,6 +1367,7 @@ QUnit.test( "ajaxSubmit", function( assert ) { $( "#user" ).val( "Peter" ); $( "#password" ).val( "foobar" ); jQuery( "#signupForm" ).validate( { + debug: false, submitHandler: function( form ) { jQuery( form ).ajaxSubmit( { success: function( response ) { @@ -1377,6 +1375,8 @@ QUnit.test( "ajaxSubmit", function( assert ) { done(); } } ); + + return false; } } ); jQuery( "#signupForm" ).triggerHandler( "submit" ); @@ -2424,7 +2424,6 @@ QUnit.test( "calling blur on ignored element", function( assert ) { form.validate( { ignore: ".ignore", - submitHandler: $.noop, invalidHandler: function() { $( "#ss1" ).blur(); } From 7c22d68a4b906498f7d1b76a5751135f0d8266a6 Mon Sep 17 00:00:00 2001 From: Javier Lopez Casanello Date: Sun, 29 Jul 2018 21:41:53 -0300 Subject: [PATCH 046/100] Core: Use of element.isContentEditable instead of hasAttribute (#2142) Fixes not supported method hasAttribute on IE7 Fixes #2141 --- src/core.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index ac7e25763..44f881cbe 100644 --- a/src/core.js +++ b/src/core.js @@ -132,7 +132,7 @@ $.extend( $.fn, { return; } - if ( !element.form && element.hasAttribute( "contenteditable" ) ) { + if ( !element.form && element.isContentEditable ) { element.form = this.closest( "form" )[ 0 ]; element.name = this.attr( "name" ); } @@ -395,7 +395,7 @@ $.extend( $.validator, { function delegate( event ) { // Set form expando on contenteditable - if ( !this.form && this.hasAttribute( "contenteditable" ) ) { + if ( !this.form && this.isContentEditable ) { this.form = $( this ).closest( "form" )[ 0 ]; this.name = $( this ).attr( "name" ); } @@ -634,7 +634,7 @@ $.extend( $.validator, { } // Set form expando on contenteditable - if ( this.hasAttribute( "contenteditable" ) ) { + if ( this.isContentEditable ) { this.form = $( this ).closest( "form" )[ 0 ]; this.name = name; } @@ -697,7 +697,7 @@ $.extend( $.validator, { return element.validity.badInput ? "NaN" : $element.val(); } - if ( element.hasAttribute( "contenteditable" ) ) { + if ( element.isContentEditable ) { val = $element.text(); } else { val = $element.val(); From 47e0d9272e3d677a004a4f58f5b09042efb901a8 Mon Sep 17 00:00:00 2001 From: Marco Grossi Date: Tue, 31 Jul 2018 23:46:38 +0200 Subject: [PATCH 047/100] Localization: Add localized methods for italian culture (it) (#2195) --- src/localization/methods_it.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/localization/methods_it.js diff --git a/src/localization/methods_it.js b/src/localization/methods_it.js new file mode 100644 index 000000000..236615a34 --- /dev/null +++ b/src/localization/methods_it.js @@ -0,0 +1,12 @@ +/* + * Localized default methods for the jQuery validation plugin. + * Locale: IT + */ +$.extend( $.validator.methods, { + date: function( value, element ) { + return this.optional( element ) || /^\d\d?\-\d\d?\-\d\d\d?\d?$/.test( value ); + }, + number: function( value, element ) { + return this.optional( element ) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test( value ); + } +} ); From 5ad8de8948259abae7c3bdc5d42e463b6ca4c7b8 Mon Sep 17 00:00:00 2001 From: Hookyns Date: Sun, 19 Aug 2018 14:31:08 +0200 Subject: [PATCH 048/100] Localization: Added Czech and Slovak translations for STEP method (#2197) --- src/localization/messages_cs.js | 3 ++- src/localization/messages_sk.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/localization/messages_cs.js b/src/localization/messages_cs.js index b2d1f207e..434fdb752 100644 --- a/src/localization/messages_cs.js +++ b/src/localization/messages_cs.js @@ -19,5 +19,6 @@ $.extend( $.validator.messages, { rangelength: $.validator.format( "Prosím, zadejte od {0} do {1} znaků." ), range: $.validator.format( "Prosím, zadejte hodnotu od {0} do {1}." ), max: $.validator.format( "Prosím, zadejte hodnotu menší nebo rovnu {0}." ), - min: $.validator.format( "Prosím, zadejte hodnotu větší nebo rovnu {0}." ) + min: $.validator.format( "Prosím, zadejte hodnotu větší nebo rovnu {0}." ), + step: $.validator.format( "Musí být násobkem čísla {0}." ) } ); diff --git a/src/localization/messages_sk.js b/src/localization/messages_sk.js index 044a02709..962625fbf 100644 --- a/src/localization/messages_sk.js +++ b/src/localization/messages_sk.js @@ -16,5 +16,6 @@ $.extend( $.validator.messages, { range: $.validator.format( "Musí byť medzi {0} a {1}." ), max: $.validator.format( "Nemôže byť viac ako {0}." ), min: $.validator.format( "Nemôže byť menej ako {0}." ), - creditcard: "Číslo platobnej karty musí byť platné." + creditcard: "Číslo platobnej karty musí byť platné.", + step: $.validator.format( "Musí byť násobkom čísla {0}." ) } ); From 01ce49cf36e38a1156f8cbbf735ed9a2de6fc5b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cleiton=20da=20Silva=20Mendon=C3=A7a?= Date: Tue, 21 Aug 2018 14:04:07 +0100 Subject: [PATCH 049/100] Additional: Add Brazillian PIS/NIS number validation method (#2204) --- src/additional/nisBR.js | 57 ++++++++++++++++++++++++++++++ src/localization/messages_pt_BR.js | 3 +- test/methods.js | 13 +++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/additional/nisBR.js diff --git a/src/additional/nisBR.js b/src/additional/nisBR.js new file mode 100644 index 000000000..7a685d1cb --- /dev/null +++ b/src/additional/nisBR.js @@ -0,0 +1,57 @@ +/** + * Created for project jquery-validation. + * @Description Brazillian PIS or NIS number (Número de Identificação Social Pis ou Pasep) is the equivalent of a + * Brazilian tax registration number NIS of PIS numbers have 11 digits in total: 10 numbers followed by 1 check numbers + * that are being used for validation. + * @copyright (c) 21/08/2018 13:14, Cleiton da Silva Mendonça + * @author Cleiton da Silva Mendonça + * @link http://gitlab.com/csmendonca Gitlab of Cleiton da Silva Mendonça + * @link http://github.com/csmendonca Github of Cleiton da Silva Mendonça + */ +$.validator.addMethod( "nisBR", function( value ) { + var number; + var cn; + var sum = 0; + var dv; + var count; + var multiplier; + + // Removing special characters from value + value = value.replace( /([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "" ); + + // Checking value to have 11 digits only + if ( value.length !== 11 ) { + return false; + } + + //Get check number of value + cn = parseInt( value.substring( 10, 11 ), 10 ); + + //Get number with 10 digits of the value + number = parseInt( value.substring( 0, 10 ), 10 ); + + for ( count = 2; count < 12; count++ ) { + multiplier = count; + if ( count === 10 ) { + multiplier = 2; + } + if ( count === 11 ) { + multiplier = 3; + } + sum += ( ( number % 10 ) * multiplier ); + number = parseInt( number / 10, 10 ); + } + dv = ( sum % 11 ); + + if ( dv > 1 ) { + dv = ( 11 - dv ); + } else { + dv = 0; + } + + if ( cn === dv ) { + return true; + } else { + return false; + } +}, "Please specify a valid NIS/PIS number" ); diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js index 504c3042c..08c2c94bd 100644 --- a/src/localization/messages_pt_BR.js +++ b/src/localization/messages_pt_BR.js @@ -72,5 +72,6 @@ $.extend( $.validator.messages, { vinUS: "O número de identificação de veículo informado (VIN) é inválido.", zipcodeUS: "Por favor, forneça um código postal americano válido.", ziprange: "O código postal deve estar entre 902xx-xxxx e 905xx-xxxx", - cpfBR: "Por favor, forneça um CPF válido." + cpfBR: "Por favor, forneça um CPF válido.", + nisBR: "Por favor, forneça um NIS/PIS válido" } ); diff --git a/test/methods.js b/test/methods.js index db2d67169..ad2662c7e 100644 --- a/test/methods.js +++ b/test/methods.js @@ -1717,6 +1717,19 @@ QUnit.test( "cpfBR", function( assert ) { assert.ok( !method( "11144477737" ), "Invalid CPF Number: 2nd check number failed" ); } ); +QUnit.test( "nisBR", function( assert ) { + var method = methodTest( "nisBR" ); + assert.ok( method( "10757995753" ), "Valid NIS/PIS Number" ); + assert.ok( method( "107.57995.75-3" ), "Valid NIS/PIS Number" ); + assert.ok( method( "107.579.957-53" ), "Valid NIS/PIS Number" ); + assert.ok( method( "107-579-957-53" ), "Valid NIS/PIS Number" ); + assert.ok( method( "107.579.957.5-3" ), "Valid NIS/PIS Number" ); + assert.ok( !method( "99999999999" ), "Invalid NIS/PIS Number: dump data" ); + assert.ok( !method( "1075799575" ), "Invalid NIS/PIS Number: < 11 digits" ); + assert.ok( !method( "111444777355" ), "Invalid NIS/PIS Number: > 11 digits" ); + assert.ok( !method( "10757995752" ), "Invalid NIS/PIS Number: check number failed" ); +} ); + QUnit.test( "file accept - image wildcard", function( assert ) { var input = acceptFileDummyInput( "test.png", "image/png" ), $form = $( "
" ), From 7d0be01cf4735c9881bb51cf4c664310b3a28467 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 9 Sep 2018 19:28:09 +0200 Subject: [PATCH 050/100] prepare 1.18.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b1e91017..9d27aa4a8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.17.1-pre", + "version": "1.18.0-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From e747a4fae13646bb2ab5d587186c29b0a4cac3b8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 9 Sep 2018 20:22:29 +0200 Subject: [PATCH 051/100] Build: Updating the master version to 1.18.1-pre. --- changelog.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index cc7be908b..b4f142f8c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,57 @@ +1.18.0 / 2018-09-09 +=================== + +## Additional + * Add Brazillian PIS/NIS number validation method (#2204) + * Add validation method for Polish telephone number (#2136) + * Updated link to EAN docs in creditcard.js (#2120) + * Allow N11 exchange for non-geo US phone (#2098) + * Add new BIN range for MasterCard (#2088) + * Add maxfiles, maxsize and maxsizetotal methods (#2087) + * Add greaterThan and lessThan methods (#2061) + +## Build + * Test on node 6.x and drop node 0.12.x (#2133) + * Generate sub-resource integrity hashes of the distribution files (#2082) + * Include localization files in tagged releases (#2057) + * Include minified version of additional methods in npm package (#2057) + +## Core + * Don't call submitHandler when in debug mode (#2193) + * Cast empty data attributes to 'true' (#2182) + * Ignore elements that belong to other/nested forms (#2147) + * Use element.isContentEditable instead of hasAttribute (#2142) + * Add deprecation warning to 'date' method (#2138) + * Allow the normalizer to return any value (#2054) + * Guard against null & undefined values in required method (#2053) + +## Demo + * Add sample code for Bootstrap 4 usage (#2173) + +## Localization + * Added Czech and Slovak translations for STEP method (#2197) + * Add localized methods for italian culture (it) (#2195) + * Add step validation string to message_zh (#2177) + * Fix typo in pt-BR localization file (#2139) + * Add message for phonePL method (#2136) + * Update Norwegian language file (#2132) + * Update Persian language file (#2122) + * Update German language file (#2115) + * Fix meaning in Bulgarian sentence (#2112) + * Add remote translation to no (#2097) + * Fixed wrong placeholder in vi translation (#2085) + * Add missing format method in message_{fr,tr}.js files (#2075) + * Fix typos in messages_pt_BR.js (#2073) + * Add new danish translations (#2067) + * Add Swedish validation message for remote (#2066) + +## Test + * Cast empty data attributes to 'true' (#2182) + * Ignore elements that belong to other/nested forms (#2147) + * Add tests for phonePL method (#2136) + * Add missing description to a test (#2055) + * Required method should return false for null & undefined values (#2053) + 1.17.0 / 2017-07-20 ================== diff --git a/package.json b/package.json index 9d27aa4a8..ec3b5f274 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.18.0-pre", + "version": "1.18.1-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From 061e5af8528dc3ed904ca27fdf365c3531d4027c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 9 Sep 2018 20:31:37 +0200 Subject: [PATCH 052/100] Build: add more release docs --- build/release.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/release.js b/build/release.js index 7ba8a04fc..338f7279b 100644 --- a/build/release.js +++ b/build/release.js @@ -1,13 +1,15 @@ /* Release checklist - Run `git changelog` and edit to match previous output (this should make use of jquey-release instead) - make sure the correct 'x.y.z-pre' version is defined in package.json +- cd into your local https://github.com/jquery/jquery-release fork - pull latest https://github.com/jquery/jquery-release - disable _generateChangelog task in release.js (BOOOO) - run node release.js --remote=jquery-validation/jquery-validation - Wait a while, verify and confirm each step -- Create GitHub release: Pick the new tag, add changelog, upload zip +- Create GitHub release: Pick the new tag, add changelog, upload zip (from __release/repo/dist/*.zip) - Upload to NPM + cd into your local jquery-validation fork git fetch --tags jquery-validation git checkout tags/X.YY.Z npm publish From 3a7e59365429598ef8612e8d57580870178c5a52 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 9 Sep 2018 20:37:37 +0200 Subject: [PATCH 053/100] Build: add more release docs --- build/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release.js b/build/release.js index 338f7279b..a9576181f 100644 --- a/build/release.js +++ b/build/release.js @@ -10,7 +10,7 @@ - Create GitHub release: Pick the new tag, add changelog, upload zip (from __release/repo/dist/*.zip) - Upload to NPM cd into your local jquery-validation fork - git fetch --tags jquery-validation + git fetch --tags upstream git checkout tags/X.YY.Z npm publish - Update MS CDN (Ping Chris Sfanos) From e1f99a76acba73d978851255548d61f84ea7a2f1 Mon Sep 17 00:00:00 2001 From: Cory Silva <2672972+coryasilva@users.noreply.github.com> Date: Wed, 10 Oct 2018 02:19:45 -0700 Subject: [PATCH 054/100] Additional: Add ABA Routing Number Validation (#2216) --- src/additional/abaRoutingNumber.js | 31 +++++++++++++++++++++++++++++ test/additional/abaRoutingNumber.js | 23 +++++++++++++++++++++ test/index.html | 1 + 3 files changed, 55 insertions(+) create mode 100644 src/additional/abaRoutingNumber.js create mode 100644 test/additional/abaRoutingNumber.js diff --git a/src/additional/abaRoutingNumber.js b/src/additional/abaRoutingNumber.js new file mode 100644 index 000000000..c8bac54b2 --- /dev/null +++ b/src/additional/abaRoutingNumber.js @@ -0,0 +1,31 @@ +/** + * This is used in the United States to process payments, deposits, + * or transfers using the Automated Clearing House (ACH) or Fedwire + * systems. A very common use case would be to validate a form for + * an ACH bill payment. + */ +$.validator.addMethod( "abaRoutingNumber", function( value ) { + var checksum = 0; + var tokens = value.split( "" ); + var length = tokens.length; + + // Length Check + if ( length !== 9 ) { + return false; + } + + // Calc the checksum + // https://en.wikipedia.org/wiki/ABA_routing_transit_number + for ( var i = 0; i < length; i += 3 ) { + checksum += parseInt( tokens[ i ], 10 ) * 3 + + parseInt( tokens[ i + 1 ], 10 ) * 7 + + parseInt( tokens[ i + 2 ], 10 ); + } + + // If not zero and divisible by 10 then valid + if ( checksum !== 0 && checksum % 10 === 0 ) { + return true; + } + + return false; +}, "Please enter a valid routing number." ); diff --git a/test/additional/abaRoutingNumber.js b/test/additional/abaRoutingNumber.js new file mode 100644 index 000000000..2cc2254fe --- /dev/null +++ b/test/additional/abaRoutingNumber.js @@ -0,0 +1,23 @@ +QUnit.test( "abaRoutingNumber", function( assert ) { + var method = methodTest( "abaRoutingNumber" ); + + // Bounds + assert.ok( !method( "12345678" ), "Invalid routing number." ); + assert.ok( !method( "1234567890" ), "Invalid routing number." ); + + // Checksum + assert.ok( !method( "123456789" ), "Invalid routing number." ); + assert.ok( method( "123456780" ), "Valid routing number." ); + assert.ok( method( "123123123" ), "Valid routing number." ); + assert.ok( method( "021000021" ), "Valid routing number." ); + assert.ok( method( "011401533" ), "Valid routing number." ); + assert.ok( method( "091000019" ), "Valid routing number." ); + + // Garbage + assert.ok( !method( "asdf" ), "Invalid routing number." ); + assert.ok( !method( "asdfasdfa" ), "Invalid routing number." ); + assert.ok( !method( "&&abcdefg" ), "Invalid routing number." ); + assert.ok( !method( "||abcdefg" ), "Invalid routing number." ); + assert.ok( !method( "!abcdefgh" ), "Invalid routing number." ); + assert.ok( !method( "abcd+efgh" ), "Invalid routing number." ); +} ); diff --git a/test/index.html b/test/index.html index d02732856..84ecc38fd 100644 --- a/test/index.html +++ b/test/index.html @@ -17,6 +17,7 @@ + From 1e2a9ea682d935d370edcc0cba92166e5ba40d79 Mon Sep 17 00:00:00 2001 From: Zhiliang Xu Date: Tue, 16 Oct 2018 15:15:56 +0800 Subject: [PATCH 055/100] Fix a typo: "the the" -> "the" (#2226) --- src/additional/creditcardtypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/additional/creditcardtypes.js b/src/additional/creditcardtypes.js index 6b9285be7..81e0dc040 100644 --- a/src/additional/creditcardtypes.js +++ b/src/additional/creditcardtypes.js @@ -1,5 +1,5 @@ /* NOTICE: Modified version of Castle.Components.Validator.CreditCardValidator - * Redistributed under the the Apache License 2.0 at http://www.apache.org/licenses/LICENSE-2.0 + * Redistributed under the Apache License 2.0 at http://www.apache.org/licenses/LICENSE-2.0 * Valid Types: mastercard, visa, amex, dinersclub, enroute, discover, jcb, unknown, all (overrides all other settings) */ $.validator.addMethod( "creditcardtypes", function( value, element, param ) { From e83a2409465c0992746d19555c7cb4b34f882100 Mon Sep 17 00:00:00 2001 From: Saeed Prez Date: Thu, 18 Oct 2018 12:44:26 +0200 Subject: [PATCH 056/100] Localization: Add Swedish translation for pattern (#2227) --- src/localization/messages_sv.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/localization/messages_sv.js b/src/localization/messages_sv.js index 327bdd762..0ef33285c 100644 --- a/src/localization/messages_sv.js +++ b/src/localization/messages_sv.js @@ -18,5 +18,6 @@ $.extend( $.validator.messages, { range: $.validator.format( "Ange ett värde mellan {0} och {1}." ), max: $.validator.format( "Ange ett värde som är mindre eller lika med {0}." ), min: $.validator.format( "Ange ett värde som är större eller lika med {0}." ), - creditcard: "Ange ett korrekt kreditkortsnummer." + creditcard: "Ange ett korrekt kreditkortsnummer.", + pattern: "Ogiltigt format." } ); From fcf782e2c77944bb3eddfe513743ebafe3abefcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Issamu=20Francisco?= Date: Mon, 5 Nov 2018 18:27:34 -0200 Subject: [PATCH 057/100] Additional: Add Brazillian CNH number (Carteira Nacional de Habilitacao) (#2234) --- src/additional/cnhBR.js | 49 ++++++++++++++++++++++++++++++ src/localization/messages_pt_BR.js | 3 +- test/additional/cnhBR.js | 6 ++++ test/index.html | 7 +++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/additional/cnhBR.js create mode 100644 test/additional/cnhBR.js diff --git a/src/additional/cnhBR.js b/src/additional/cnhBR.js new file mode 100644 index 000000000..67ea7965a --- /dev/null +++ b/src/additional/cnhBR.js @@ -0,0 +1,49 @@ +/* + * Brazillian CNH number (Carteira Nacional de Habilitacao) is the License Driver number. + * CNH numbers have 11 digits in total: 9 numbers followed by 2 check numbers that are being used for validation. + */ +$.validator.addMethod( "cnhBR", function( value ) { + + // Removing special characters from value + value = value.replace( /([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "" ); + + // Checking value to have 11 digits only + if ( value.length !== 11 ) { + return false; + } + + var sum = 0, dsc = 0, firstChar, + firstCN, secondCN, i, j, v; + + firstChar = value.charAt( 0 ); + + if ( new Array( 12 ).join( firstChar ) === value ) { + return false; + } + + // Step 1 - using first Check Number: + for ( i = 0, j = 9, v = 0; i < 9; ++i, --j ) { + sum += +( value.charAt( i ) * j ); + } + + firstCN = sum % 11; + if ( firstCN >= 10 ) { + firstCN = 0; + dsc = 2; + } + + sum = 0; + for ( i = 0, j = 1, v = 0; i < 9; ++i, ++j ) { + sum += +( value.charAt( i ) * j ); + } + + secondCN = sum % 11; + if ( secondCN >= 10 ) { + secondCN = 0; + } else { + secondCN = secondCN - dsc; + } + + return ( String( firstCN ).concat( secondCN ) === value.substr( -2 ) ); + +}, "Please specify a valid CNH number" ); diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js index 08c2c94bd..4f9effad8 100644 --- a/src/localization/messages_pt_BR.js +++ b/src/localization/messages_pt_BR.js @@ -73,5 +73,6 @@ $.extend( $.validator.messages, { zipcodeUS: "Por favor, forneça um código postal americano válido.", ziprange: "O código postal deve estar entre 902xx-xxxx e 905xx-xxxx", cpfBR: "Por favor, forneça um CPF válido.", - nisBR: "Por favor, forneça um NIS/PIS válido" + nisBR: "Por favor, forneça um NIS/PIS válido", + cnhBR: "Por favor, forneça um CNH válido." } ); diff --git a/test/additional/cnhBR.js b/test/additional/cnhBR.js new file mode 100644 index 000000000..99bdf847d --- /dev/null +++ b/test/additional/cnhBR.js @@ -0,0 +1,6 @@ +QUnit.test( "cnhBR", function( assert ) { + var method = methodTest( "cnhBR" ); + assert.ok( method( "00000000119" ), "Valid driver's license number" ); + assert.ok( !method( "11111111111" ), "Invalid driver's license number" ); + assert.ok( !method( "asdf" ), "Invalid driver's license number" ); +} ); diff --git a/test/index.html b/test/index.html index 84ecc38fd..bf22a640a 100644 --- a/test/index.html +++ b/test/index.html @@ -15,6 +15,7 @@ + @@ -447,6 +448,12 @@

+ +
+ + +
+

From 743077cf2906df9c9d981ba25bb9ac1b2a9238ac Mon Sep 17 00:00:00 2001 From: Julio Spader Date: Mon, 5 Nov 2018 18:59:39 -0200 Subject: [PATCH 058/100] Additional: Add Brazillian CNPJ validation rule (#2222) --- src/additional/cnpjBR.js | 69 ++++++++++++++++++++++++++++++ src/localization/messages_pt_BR.js | 3 +- test/methods.js | 20 +++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/additional/cnpjBR.js diff --git a/src/additional/cnpjBR.js b/src/additional/cnpjBR.js new file mode 100644 index 000000000..41834380e --- /dev/null +++ b/src/additional/cnpjBR.js @@ -0,0 +1,69 @@ +/* + * Brazillian value number (Cadastrado de Pessoas Juridica). + * value numbers have 14 digits in total: 12 numbers followed by 2 check numbers that are being used for validation. + */ +$.validator.addMethod( "cnpjBR", function( value ) { + + // Removing no number + value = value.replace( /[^\d]+/g, "" ); + + // Checking value to have 14 digits only + if ( value.length !== 14 ) { + return false; + } + + // Elimina values invalidos conhecidos + if ( value === "00000000000000" || + value === "11111111111111" || + value === "22222222222222" || + value === "33333333333333" || + value === "44444444444444" || + value === "55555555555555" || + value === "66666666666666" || + value === "77777777777777" || + value === "88888888888888" || + value === "99999999999999" ) { + return false; + } + + // Valida DVs + var tamanho = ( value.length - 2 ); + var numeros = value.substring( 0, tamanho ); + var digitos = value.substring( tamanho ); + var soma = 0; + var pos = tamanho - 7; + + for ( var i = tamanho; i >= 1; i-- ) { + soma += numeros.charAt( tamanho - i ) * pos--; + if ( pos < 2 ) { + pos = 9; + } + } + + var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; + + if ( resultado !== parseInt( digitos.charAt( 0 ), 10 ) ) { + return false; + } + + tamanho = tamanho + 1; + numeros = value.substring( 0, tamanho ); + soma = 0; + pos = tamanho - 7; + + for ( var il = tamanho; il >= 1; il-- ) { + soma += numeros.charAt( tamanho - il ) * pos--; + if ( pos < 2 ) { + pos = 9; + } + } + + resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; + + if ( resultado !== parseInt( digitos.charAt( 1 ), 10 ) ) { + return false; + } + + return true; + +}, "Please specify a CNPJ value number" ); diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js index 4f9effad8..cfd018de8 100644 --- a/src/localization/messages_pt_BR.js +++ b/src/localization/messages_pt_BR.js @@ -74,5 +74,6 @@ $.extend( $.validator.messages, { ziprange: "O código postal deve estar entre 902xx-xxxx e 905xx-xxxx", cpfBR: "Por favor, forneça um CPF válido.", nisBR: "Por favor, forneça um NIS/PIS válido", - cnhBR: "Por favor, forneça um CNH válido." + cnhBR: "Por favor, forneça um CNH válido.", + cnpjBR: "Por favor, forneça um CNPJ válido." } ); diff --git a/test/methods.js b/test/methods.js index ad2662c7e..f7a193536 100644 --- a/test/methods.js +++ b/test/methods.js @@ -1717,6 +1717,26 @@ QUnit.test( "cpfBR", function( assert ) { assert.ok( !method( "11144477737" ), "Invalid CPF Number: 2nd check number failed" ); } ); +QUnit.test( "cnpjBR", function( assert ) { + var method = methodTest( "cnpjBR" ); + assert.ok( method( "18517604000175" ), "Valid CNPJ Number" ); + assert.ok( method( "18.517.604/0001-75" ), "Valid CNPJ Number" ); + assert.ok( method( "06994660000111" ), "Valid CNPJ Number" ); + assert.ok( method( "06.994.660/0001-11" ), "Valid CNPJ Number" ); + assert.ok( !method( "00000000000000" ), "Invalid CNPJ Number: dump data" ); + assert.ok( !method( "11111111111111" ), "Invalid CNPJ Number: dump data" ); + assert.ok( !method( "22222222222222" ), "Invalid CNPJ Number: dump data" ); + assert.ok( !method( "99999999999999" ), "Invalid CNPJ Number: dump data" ); + assert.ok( !method( "8517604000175" ), "Invalid CNPJ Number: < 14 digits" ); + assert.ok( !method( "8.517.604/0001-75" ), "Invalid CNPJ Number: < 14 digits" ); + assert.ok( !method( "1185176040001750" ), "Invalid CNPJ Number: > 14 digits" ); + assert.ok( !method( "18.517.604/0001-750" ), "Invalid CNPJ Number: > 14 digits" ); + assert.ok( !method( "18517604000174" ), "Invalid CNPJ Number" ); + assert.ok( !method( "18.517.604/0001-74" ), "Invalid CNPJ Number" ); + assert.ok( !method( "06994660000211" ), "Invalid CNPJ Number" ); + assert.ok( !method( "06.994.660/0002-11" ), "Invalid CNPJ Number" ); +} ); + QUnit.test( "nisBR", function( assert ) { var method = methodTest( "nisBR" ); assert.ok( method( "10757995753" ), "Valid NIS/PIS Number" ); From 3242f0f3e7ee1db1de6b9c8e295072a9aa5d8d63 Mon Sep 17 00:00:00 2001 From: jehadja Date: Tue, 6 Nov 2018 22:53:31 +0300 Subject: [PATCH 059/100] Additional: Add validation rule for mobile number of Russia Federation (#2207) --- src/additional/mobileRU.js | 4 ++++ test/methods.js | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/additional/mobileRU.js diff --git a/src/additional/mobileRU.js b/src/additional/mobileRU.js new file mode 100644 index 000000000..7006d09b4 --- /dev/null +++ b/src/additional/mobileRU.js @@ -0,0 +1,4 @@ +$.validator.addMethod( "mobileRU", function( phone_number, element ) { + var ruPhone_number = phone_number.replace( /\(|\)|\s+|-/g, "" ); + return this.optional( element ) || ruPhone_number.length > 9 && /^((\+7|7|8)+([0-9]){10})$/.test( ruPhone_number ); +}, "Please specify a valid mobile number" ); diff --git a/test/methods.js b/test/methods.js index f7a193536..40b7ce8fd 100644 --- a/test/methods.js +++ b/test/methods.js @@ -868,6 +868,15 @@ QUnit.test( "mobileUK", function( assert ) { assert.ok( !method( "+4444342343234" ), "Invalid UK Mobile Number" ); } ); +QUnit.test( "mobileRU", function( assert ) { + var method = methodTest( "mobileRU" ); + assert.ok( method( "+74957207089" ), "Valid RU Mobile Number" ); + assert.ok( method( "84957207089" ), "Valid RU Mobile Number" ); + assert.ok( !method( "+447604234323" ), "Invalid RU Mobile Number" ); + assert.ok( !method( "9477342343234" ), "Invalid RU Mobile Number" ); + assert.ok( !method( "344342343234" ), "Invalid RU Mobile Number" ); +} ); + QUnit.test( "dateITA", function( assert ) { var method = methodTest( "dateITA" ); assert.ok( method( "01/01/1900" ), "Valid date ITA" ); From 2dfd33c81043710dfd887a2bfc03a0d85e884f61 Mon Sep 17 00:00:00 2001 From: Julio Spader Date: Sun, 18 Nov 2018 09:45:39 -0200 Subject: [PATCH 060/100] Additional: Don't fail when field is optional in CNPJBR & CPFBR rules (#2236) --- src/additional/cnpjBR.js | 7 ++++++- src/additional/cpfBR.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/additional/cnpjBR.js b/src/additional/cnpjBR.js index 41834380e..43e3bfcf6 100644 --- a/src/additional/cnpjBR.js +++ b/src/additional/cnpjBR.js @@ -2,7 +2,12 @@ * Brazillian value number (Cadastrado de Pessoas Juridica). * value numbers have 14 digits in total: 12 numbers followed by 2 check numbers that are being used for validation. */ -$.validator.addMethod( "cnpjBR", function( value ) { +$.validator.addMethod( "cnpjBR", function( value, element ) { + "use strict"; + + if ( this.optional( element ) ) { + return true; + } // Removing no number value = value.replace( /[^\d]+/g, "" ); diff --git a/src/additional/cpfBR.js b/src/additional/cpfBR.js index 37f083e5e..a2b1611b3 100644 --- a/src/additional/cpfBR.js +++ b/src/additional/cpfBR.js @@ -2,7 +2,12 @@ * Brazillian CPF number (Cadastrado de Pessoas Físicas) is the equivalent of a Brazilian tax registration number. * CPF numbers have 11 digits in total: 9 numbers followed by 2 check numbers that are being used for validation. */ -$.validator.addMethod( "cpfBR", function( value ) { +$.validator.addMethod( "cpfBR", function( value, element ) { + "use strict"; + + if ( this.optional( element ) ) { + return true; + } // Removing special characters from value value = value.replace( /([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "" ); From dd187b016a1b4eef22ae93500eb37a44bf2ecd0d Mon Sep 17 00:00:00 2001 From: Brahim Arkni Date: Sun, 18 Nov 2018 11:48:55 +0000 Subject: [PATCH 061/100] Core: Fix contenteditable detection's regression introduced in #2142 (#2235) Fixes #2211 Fixes #2214 Fixes #2217 Fixes #2225 Fixes #2233 --- src/core.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index 44f881cbe..08352d41c 100644 --- a/src/core.js +++ b/src/core.js @@ -125,6 +125,7 @@ $.extend( $.fn, { // https://jqueryvalidation.org/rules/ rules: function( command, argument ) { var element = this[ 0 ], + isContentEditable = typeof this.attr( "contenteditable" ) !== "undefined" && this.attr( "contenteditable" ) !== "false", settings, staticRules, existingRules, data, param, filtered; // If nothing is selected, return empty object; can't chain anyway @@ -132,7 +133,7 @@ $.extend( $.fn, { return; } - if ( !element.form && element.isContentEditable ) { + if ( !element.form && isContentEditable ) { element.form = this.closest( "form" )[ 0 ]; element.name = this.attr( "name" ); } @@ -393,9 +394,10 @@ $.extend( $.validator, { } ); function delegate( event ) { + var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false"; // Set form expando on contenteditable - if ( !this.form && this.isContentEditable ) { + if ( !this.form && isContentEditable ) { this.form = $( this ).closest( "form" )[ 0 ]; this.name = $( this ).attr( "name" ); } @@ -629,12 +631,14 @@ $.extend( $.validator, { .not( this.settings.ignore ) .filter( function() { var name = this.name || $( this ).attr( "name" ); // For contenteditable + var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false"; + if ( !name && validator.settings.debug && window.console ) { console.error( "%o has no name assigned", this ); } // Set form expando on contenteditable - if ( this.isContentEditable ) { + if ( isContentEditable ) { this.form = $( this ).closest( "form" )[ 0 ]; this.name = name; } @@ -689,6 +693,7 @@ $.extend( $.validator, { elementValue: function( element ) { var $element = $( element ), type = element.type, + isContentEditable = typeof $element.attr( "contenteditable" ) !== "undefined" && $element.attr( "contenteditable" ) !== "false", val, idx; if ( type === "radio" || type === "checkbox" ) { @@ -697,7 +702,7 @@ $.extend( $.validator, { return element.validity.badInput ? "NaN" : $element.val(); } - if ( element.isContentEditable ) { + if ( isContentEditable ) { val = $element.text(); } else { val = $element.val(); From f242795bef291a31a448c6e1a168235499d626a9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 28 Nov 2018 19:03:36 +0100 Subject: [PATCH 062/100] chore: next version will be 1.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec3b5f274..fa5835e3b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.18.1-pre", + "version": "1.19.0-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From d9840a5e61ddb7bedf017716ab14c7cf5f2ef9f2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 28 Nov 2018 19:27:18 +0100 Subject: [PATCH 063/100] Build: Updating the master version to 1.19.1-pre. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa5835e3b..1393208bb 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.19.0-pre", + "version": "1.19.1-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From d1c73fe289d7d8f19c5b0ee91ece9b25a0949a6c Mon Sep 17 00:00:00 2001 From: Ryan Chang Date: Fri, 14 Dec 2018 03:43:54 +0800 Subject: [PATCH 064/100] Localization: Add zh_TW translation for step message (#2245) --- src/localization/messages_zh_TW.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/localization/messages_zh_TW.js b/src/localization/messages_zh_TW.js index f6d46c235..638a5452e 100644 --- a/src/localization/messages_zh_TW.js +++ b/src/localization/messages_zh_TW.js @@ -19,6 +19,7 @@ $.extend( $.validator.messages, { minlength: $.validator.format( "最少 {0} 個字" ), rangelength: $.validator.format( "請輸入長度為 {0} 至 {1} 之間的字串" ), range: $.validator.format( "請輸入 {0} 至 {1} 之間的數值" ), + step: $.validator.format( "請輸入 {0} 的整數倍值" ), max: $.validator.format( "請輸入不大於 {0} 的數值" ), min: $.validator.format( "請輸入不小於 {0} 的數值" ) } ); From a9c20ec280ce3a968abbca5611dcd63f412b5d34 Mon Sep 17 00:00:00 2001 From: Stephen Scott Date: Thu, 13 Dec 2018 19:46:59 +0000 Subject: [PATCH 065/100] Core: change focus() to trigger("focus") (#2243) Change focus() to trigger("focus") so that jQuery Migrate 3.x doesn't flag it as deprecated. --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 08352d41c..ccb8d4cbe 100644 --- a/src/core.js +++ b/src/core.js @@ -602,7 +602,7 @@ $.extend( $.validator, { try { $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [] ) .filter( ":visible" ) - .focus() + .trigger( "focus" ) // Manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find .trigger( "focusin" ); From 824c9897b28f42a5dabc735a11f03c02cd5446cb Mon Sep 17 00:00:00 2001 From: Dusan Orlovic Date: Sun, 20 Jan 2019 22:28:06 +0100 Subject: [PATCH 066/100] Localization: Adding Serbian translation for step method message (#2251) --- src/localization/messages_sr.js | 3 ++- src/localization/messages_sr_lat.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/localization/messages_sr.js b/src/localization/messages_sr.js index 7cdd4297c..d6f9bec61 100644 --- a/src/localization/messages_sr.js +++ b/src/localization/messages_sr.js @@ -19,5 +19,6 @@ $.extend( $.validator.messages, { rangelength: $.validator.format( "Унесите вредност дугачку између {0} и {1} карактера." ), range: $.validator.format( "Унесите вредност између {0} и {1}." ), max: $.validator.format( "Унесите вредност мању или једнаку {0}." ), - min: $.validator.format( "Унесите вредност већу или једнаку {0}." ) + min: $.validator.format( "Унесите вредност већу или једнаку {0}." ), + step: $.validator.format( "Унесите вредност која је умножак броја {0}." ) } ); diff --git a/src/localization/messages_sr_lat.js b/src/localization/messages_sr_lat.js index f12bfb5e6..43666f98d 100644 --- a/src/localization/messages_sr_lat.js +++ b/src/localization/messages_sr_lat.js @@ -19,5 +19,6 @@ $.extend( $.validator.messages, { rangelength: $.validator.format( "Unesite vrednost dugačku između {0} i {1} karaktera." ), range: $.validator.format( "Unesite vrednost između {0} i {1}." ), max: $.validator.format( "Unesite vrednost manju ili jednaku {0}." ), - min: $.validator.format( "Unesite vrednost veću ili jednaku {0}." ) + min: $.validator.format( "Unesite vrednost veću ili jednaku {0}." ), + step: $.validator.format( "Unesite vrednost koja je umnožak broja {0}." ) } ); From 01ca87912d5e73eb15e285037fd46bdc023a5618 Mon Sep 17 00:00:00 2001 From: Ahmed Gaber Date: Sat, 26 Jan 2019 16:42:09 +0200 Subject: [PATCH 067/100] Build: Set jQuery as a peer dependency (#2248) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1393208bb..3ad550d54 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "dist/jquery.validate.min.js" ], "main": "dist/jquery.validate.js", - "dependencies": { + "peerDependencies": { "jquery": "^1.7 || ^2.0 || ^3.1" }, "devDependencies": { From 05e35ea40d8053ea93038dae8a867c3ec685b5d2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 15 Jun 2019 08:26:58 +0200 Subject: [PATCH 068/100] Build: Updating the master version to 1.19.2-pre. --- changelog.md | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b4f142f8c..4d3fdff3f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,38 @@ +1.19.1 / 2019-06-15 +=================== + +## Core + * Change focus() to trigger("focus") (#2243) + +## Build + * Set jQuery as a peer dependency (#2248) + +## Localization + * Add zh_TW translation for step message (#2245) + * Adding Serbian translation for step method message (#2251) + +1.19.0 / 2018-11-28 +=================== + +## Subresource Integrity hashes + +As of 1.18.0, we started to provide Subresource Integrity hashes of all distribution files. + +The hashes for the 1.19.0 release can be found in the file [`jquery-validation-sri.json`](https://raw.githubusercontent.com/jquery-validation/jquery-validation/1.19.0/dist/jquery-validation-sri.json) under `dist` folder. + +## Additional + * Don't fail when field is optional in CNPJBR & CPFBR rules (#2236) + * Add validation rule for mobile number of Russia Federation (#2207) + * Add Brazillian CNPJ validation rule (#2222) + * Add Brazillian CNH number (Carteira Nacional de Habilitacao) (#2234) + * Add ABA Routing Number Validation (#2216) + +## Core + * Fix contenteditable detection's regression introduced in #2142 (#2235) + +## Localization + * Add Swedish translation for pattern (#2227) + 1.18.0 / 2018-09-09 =================== diff --git a/package.json b/package.json index 3ad550d54..fdecee0fc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.19.1-pre", + "version": "1.19.2-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From 5426dcbd8cef2f8a8fac834f7f9b68754b5a4185 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 15 Jun 2019 08:40:07 +0200 Subject: [PATCH 069/100] chore: updated build docs (#2288) --- build/release.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/release.js b/build/release.js index a9576181f..7d78e7e61 100644 --- a/build/release.js +++ b/build/release.js @@ -1,9 +1,9 @@ /* Release checklist - Run `git changelog` and edit to match previous output (this should make use of jquey-release instead) - make sure the correct 'x.y.z-pre' version is defined in package.json -- cd into your local https://github.com/jquery/jquery-release fork -- pull latest https://github.com/jquery/jquery-release -- disable _generateChangelog task in release.js (BOOOO) +- `cd jquery-release` into your local https://github.com/jquery/jquery-release fork +- `git pull` latest https://github.com/jquery/jquery-release +- disable _generateChangelog task in release.js (BOOOO), by commenting this lines: https://github.com/jquery/jquery-release/blob/a9823df8a5dff4c96d1f6645b09daa591adc2f06/release.js#L43-L44 - run node release.js --remote=jquery-validation/jquery-validation - Wait a while, verify and confirm each step From 25a0f146dc860e8de69d16cd95d0f5987f86e51c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 15 Jun 2019 08:50:18 +0200 Subject: [PATCH 070/100] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..978bc43f5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [staabm, Arkni] From d3748a2271223be1c23742dbf79dd918eb2158ee Mon Sep 17 00:00:00 2001 From: Brighton Balfrey Date: Wed, 13 May 2020 13:47:44 -0700 Subject: [PATCH 071/100] Core: Fixes deprecated calls to jQuery trim (#2328) Fixes #2327 Co-authored-by: Brighton Balfrey --- src/core.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index ccb8d4cbe..b7b8f3b9b 100644 --- a/src/core.js +++ b/src/core.js @@ -198,18 +198,25 @@ $.extend( $.fn, { } } ); +// JQuery trim is deprecated, provide a trim method based on String.prototype.trim +var trim = function( str ) { + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill + return str.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" ); +}; + // Custom selectors $.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables backwards compatibility to jQuery 1.7. Can be removed when dropping jQ 1.7.x support // https://jqueryvalidation.org/blank-selector/ blank: function( a ) { - return !$.trim( "" + $( a ).val() ); + return !trim( "" + $( a ).val() ); }, // https://jqueryvalidation.org/filled-selector/ filled: function( a ) { var val = $( a ).val(); - return val !== null && !!$.trim( "" + val ); + return val !== null && !!trim( "" + val ); }, // https://jqueryvalidation.org/unchecked-selector/ From cd1ce52f794d86154917403c83d1ff83b829da4b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 23 May 2020 10:32:41 +0200 Subject: [PATCH 072/100] Build: Updating the master version to 1.19.3-pre. --- changelog.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 4d3fdff3f..f36c5b70a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +1.19.2 / 2020-05-23 +=================== + +## Core + * Core: Fixes deprecated calls to jQuery trim for compat with newer jQuery core versions (#2328) + 1.19.1 / 2019-06-15 =================== diff --git a/package.json b/package.json index fdecee0fc..3becbbc83 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-validation", "title": "jQuery Validation Plugin", "description": "Client-side form validation made easy", - "version": "1.19.2-pre", + "version": "1.19.3-pre", "homepage": "https://jqueryvalidation.org/", "license": "MIT", "author": { From af445b30fc6bbe7431fd8677ddad1008b866bdda Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 23 May 2020 10:36:03 +0200 Subject: [PATCH 073/100] chore: added more release tasks --- build/release.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build/release.js b/build/release.js index 7d78e7e61..a12d7c838 100644 --- a/build/release.js +++ b/build/release.js @@ -13,6 +13,7 @@ git fetch --tags upstream git checkout tags/X.YY.Z npm publish +- double check NPM for new release https://www.npmjs.com/package/jquery-validation - Update MS CDN (Ping Chris Sfanos) - Check jsdelivr CDN: new git tags are automatically pulled, tested & merged via https://github.com/jsdelivr/jsdelivr/pulls - Check cdnjs CDN: new git tags are automatically committed into https://github.com/cdnjs/cdnjs/commits/master or ping @cdnjs From 79bed393e6f4bf6876d0e917baed7ef6447efe6a Mon Sep 17 00:00:00 2001 From: Kieran Brahney Date: Tue, 23 Jun 2020 12:25:10 +0100 Subject: [PATCH 074/100] Core: Replaced deprecated jQuery functions Replaced $.isArray and $.isFunction --- src/core.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index b7b8f3b9b..4674710f4 100644 --- a/src/core.js +++ b/src/core.js @@ -1313,7 +1313,7 @@ $.extend( $.validator, { // Evaluate parameters $.each( rules, function( rule, parameter ) { - rules[ rule ] = $.isFunction( parameter ) && rule !== "normalizer" ? parameter( element ) : parameter; + rules[ rule ] = typeof parameter === "function" && rule !== "normalizer" ? parameter( element ) : parameter; } ); // Clean number parameters @@ -1325,7 +1325,7 @@ $.extend( $.validator, { $.each( [ "rangelength", "range" ], function() { var parts; if ( rules[ this ] ) { - if ( $.isArray( rules[ this ] ) ) { + if ( Array.isArray( rules[ this ] ) ) { rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ]; } else if ( typeof rules[ this ] === "string" ) { parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ ); @@ -1454,19 +1454,19 @@ $.extend( $.validator, { // https://jqueryvalidation.org/minlength-method/ minlength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); return this.optional( element ) || length >= param; }, // https://jqueryvalidation.org/maxlength-method/ maxlength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); return this.optional( element ) || length <= param; }, // https://jqueryvalidation.org/rangelength-method/ rangelength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] ); }, From b0e3b11324a542813adf9a93c432a31d818f7c80 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Tue, 18 Aug 2020 01:10:33 -0700 Subject: [PATCH 075/100] Add Accessibility section to Readme (#2149) * Add accessibility section to readme - speaks to errorElement * Add link to errorElement in doc Co-authored-by: Joe Watkins --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index f02786c1c..bf109300a 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,27 @@ $("#myForm").validate({ }); ``` +## Accessibility +For an invalid field, the default output for the jQuery Validation Plugin is an error message in a `