Skip to content

Commit f2d525c

Browse files
mlynchjzaefferer
authored andcommitted
Fixed regex issue for decimals without leading zeroes. Added new methods test. Fixes jquery-validation#41
1 parent e30b3aa commit f2d525c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

jquery.validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ $.extend($.validator, {
10951095

10961096
// http://docs.jquery.com/Plugins/Validation/Methods/number
10971097
number: function(value, element) {
1098-
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
1098+
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
10991099
},
11001100

11011101
// http://docs.jquery.com/Plugins/Validation/Methods/digits

test/methods.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ test("number", function() {
131131
ok( method( "123.000" ), "Valid decimal" );
132132
ok( method( "123,000.00" ), "Valid decimal" );
133133
ok( method( "-123,000.00" ), "Valid decimal" );
134+
ok( method( ".100" ), "Valid decimal" );
134135
ok(!method( "1230,000.00" ), "Invalid decimal" );
135136
ok(!method( "123.0.0,0" ), "Invalid decimal" );
136137
ok(!method( "x123" ), "Invalid decimal" );

0 commit comments

Comments
 (0)