Skip to content

Commit 2ad0ca8

Browse files
committed
Core: Stop trimming value inside required method
There was never much of a point anyway, and it causes problems. Fixes jquery-validation#1498
1 parent f59bb13 commit 2ad0ca8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ $.extend( $.validator, {
11431143
if ( this.checkable( element ) ) {
11441144
return this.getLength( value, element ) > 0;
11451145
}
1146-
return $.trim( value ).length > 0;
1146+
return value.length > 0;
11471147
},
11481148

11491149
// http://jqueryvalidation.org/email-method/

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ <h3></h3>
203203
</form>
204204
<form id="form" action="formaction">
205205
<input type="text" name="action" value="Test" id="text1">
206-
<input type="text" name="text2" value=" " id="text1b">
206+
<input type="text" name="text2" value="" id="text1b">
207207
<input type="text" name="text2" value="T " id="text1c">
208208
<input type="text" name="text2" value="T" id="text2">
209209
<input type="text" name="text2" value="TestTestTest" id="text3">

test/methods.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ test("required", function() {
186186
e = $("#text1, #text1b, #hidden2, #select1, #select2");
187187
ok( method.call( v, e[0].value, e[0]), "Valid text input" );
188188
ok(!method.call( v, e[1].value, e[1]), "Invalid text input" );
189-
ok(!method.call( v, e[1].value, e[2]), "Invalid text input" );
189+
ok(!method.call( v, e[2].value, e[2]), "Invalid text input" );
190190

191-
ok(!method.call( v, e[2].value, e[3]), "Invalid select" );
192-
ok( method.call( v, e[3].value, e[4]), "Valid select" );
191+
ok(!method.call( v, e[3].value, e[3]), "Invalid select" );
192+
ok( method.call( v, e[4].value, e[4]), "Valid select" );
193193

194194
e = $("#area1, #area2, #pw1, #pw2");
195195
ok( method.call( v, e[0].value, e[0]), "Valid textarea" );

0 commit comments

Comments
 (0)