From 793fcb42e157ec74b4dc6253ca277ec20fa0c939 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Thu, 27 Jul 2017 19:27:19 +0000 Subject: [PATCH] Adds a better regexp thanks to this: https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers --- js/transaction.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/transaction.js b/js/transaction.js index f57a36f..ae755b3 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -741,7 +741,7 @@ $(function() { */ $("#redeemable_hours").spinner({ - step: 0.10, + step: 0.01, numberFormat: "n", max: obj.current_year_volunteer_hours, min: 0 @@ -752,8 +752,9 @@ $(function() { max = $this.spinner('option', 'max'), min = $this.spinner('option', 'min'); // We want only number, no alpha. - // We set it to previous default value. - if (!val.match(/^[+-]?[\d]{0,}$/)) val = $(this).data('defaultValue'); + // We set it to previous default value. + //[+-]?[\d]{0,} [+-]?([0-9]*[.])?[0-9]+ [+-]?([0-9]+([.][0-9]*)?|[.][0-9]+) + if (!val.match(/^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)$/)) val = $(this).data('defaultValue'); this.value = val > max ? max : val < min ? min : val; }).on('keydown', function (e) { // we set default value for spinner.