Skip to content

Commit

Permalink
Fixed bug #14 and wrote a test case for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
EmKayDK committed Sep 19, 2015
1 parent 6fb296c commit 273f28a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions jquery.jstepper.js
@@ -1,4 +1,4 @@
// jStepper 1.5.2
// jStepper 1.5.3

// A jQuery plugin by EmKay usable for making a numeric textfield value easy to increase or decrease.

Expand Down Expand Up @@ -75,9 +75,11 @@

if (o.overflowMode === 'ignore') {

if (o.maxValue) {
var objValueToCheck = $(this).val().indexOf("-") === 0 ? o.minValue : o.maxValue;

if ($(this).val().length >= o.maxValue.toString().length) {
if (objValueToCheck) {

if ($(this).val().length >= objValueToCheck.toString().length) {

if (
((key >= 48 && key <= 57) || (key >= 96 && key <= 105)) &&
Expand Down
8 changes: 7 additions & 1 deletion website/scripts/tests.js
Expand Up @@ -278,7 +278,7 @@ function RunQUnit() {

test('Validating value of field', function() {

expect(3);
expect(4);

$('#txtQUnit').unbind();

Expand All @@ -295,6 +295,12 @@ function RunQUnit() {
$('#txtQUnit').trigger(objBlurEvent);
equal($('#txtQUnit').val(), '123456', 'Pasting in to many dashes');

$('#txtQUnit').unbind();
$('#txtQUnit').jStepper({ minValue: -1111, maxValue: 20, overflowMode: 'ignore' });
$('#txtQUnit').val('-1');
syn.type('1', $('#txtQUnit'));
equal($('#txtQUnit').val(), '-11', 'Writing a negative number that is too long compared to maxValue');

});

// Hiding QUnit fields after testing is complete
Expand Down

0 comments on commit 273f28a

Please sign in to comment.