From 2ad0ca82daf091fc692018b38e01e896fd304015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Tue, 16 Jun 2015 19:50:11 +0200 Subject: [PATCH] Core: Stop trimming value inside required method There was never much of a point anyway, and it causes problems. Fixes #1498 --- src/core.js | 2 +- test/index.html | 2 +- test/methods.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index d617723..4487af7 100644 --- a/src/core.js +++ b/src/core.js @@ -1143,7 +1143,7 @@ $.extend( $.validator, { if ( this.checkable( element ) ) { return this.getLength( value, element ) > 0; } - return $.trim( value ).length > 0; + return value.length > 0; }, // http://jqueryvalidation.org/email-method/ diff --git a/test/index.html b/test/index.html index cf82768..408c3d1 100644 --- a/test/index.html +++ b/test/index.html @@ -203,7 +203,7 @@
- + diff --git a/test/methods.js b/test/methods.js index 610b764..c18f383 100644 --- a/test/methods.js +++ b/test/methods.js @@ -186,10 +186,10 @@ test("required", function() { e = $("#text1, #text1b, #hidden2, #select1, #select2"); ok( method.call( v, e[0].value, e[0]), "Valid text input" ); ok(!method.call( v, e[1].value, e[1]), "Invalid text input" ); - ok(!method.call( v, e[1].value, e[2]), "Invalid text input" ); + ok(!method.call( v, e[2].value, e[2]), "Invalid text input" ); - ok(!method.call( v, e[2].value, e[3]), "Invalid select" ); - ok( method.call( v, e[3].value, e[4]), "Valid select" ); + ok(!method.call( v, e[3].value, e[3]), "Invalid select" ); + ok( method.call( v, e[4].value, e[4]), "Valid select" ); e = $("#area1, #area2, #pw1, #pw2"); ok( method.call( v, e[0].value, e[0]), "Valid textarea" );