mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-14 20:35:47 +01:00
Core: Allow negative decimal with no 0 (#2483)
* Core: Allow negative decimal with no 0 * Update regex --------- Co-authored-by: METALCOMPINC\cstieg <cstieg@metalcompinc.com> Co-authored-by: Kieran <kieran.brahney@gmail.com>
This commit is contained in:
committed by
GitHub
parent
75f51237e4
commit
e837cc49be
@@ -1485,7 +1485,7 @@ $.extend( $.validator, {
|
|||||||
|
|
||||||
// https://jqueryvalidation.org/number-method/
|
// https://jqueryvalidation.org/number-method/
|
||||||
number: function( value, element ) {
|
number: function( value, element ) {
|
||||||
return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
|
return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:-?\.\d+)?$/.test( value );
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://jqueryvalidation.org/digits-method/
|
// https://jqueryvalidation.org/digits-method/
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ QUnit.test( "number", function( assert ) {
|
|||||||
assert.ok( method( "123,000.00" ), "Valid decimal" );
|
assert.ok( method( "123,000.00" ), "Valid decimal" );
|
||||||
assert.ok( method( "-123,000.00" ), "Valid decimal" );
|
assert.ok( method( "-123,000.00" ), "Valid decimal" );
|
||||||
assert.ok( method( ".100" ), "Valid decimal" );
|
assert.ok( method( ".100" ), "Valid decimal" );
|
||||||
|
assert.ok( method( "-.100" ), "Valid decimal" );
|
||||||
assert.ok( !method( "1230,000.00" ), "Invalid decimal" );
|
assert.ok( !method( "1230,000.00" ), "Invalid decimal" );
|
||||||
assert.ok( !method( "123.0.0,0" ), "Invalid decimal" );
|
assert.ok( !method( "123.0.0,0" ), "Invalid decimal" );
|
||||||
assert.ok( !method( "x123" ), "Invalid decimal" );
|
assert.ok( !method( "x123" ), "Invalid decimal" );
|
||||||
|
|||||||
Reference in New Issue
Block a user