From bdf2e244cdf422c7343efe49607054b4fbc3fc95 Mon Sep 17 00:00:00 2001 From: Leon Gersen Date: Fri, 22 Aug 2014 19:34:11 +0200 Subject: [PATCH] Fixed and issue with the numerical filter --- wNumb.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wNumb.js b/wNumb.js index 8ecfdd9..0fdafcf 100644 --- a/wNumb.js +++ b/wNumb.js @@ -204,8 +204,16 @@ var // Add the number output += input; + // Trim all non-numeric characters (allow '.' and '-'); + output = output.replace(/[^0-9\.\-.]/g, ''); + + // The value contains no parse-able number. + if ( output === '' ) { + return false; + } + // Covert to number. - output = Number(output.replace(/[^0-9\.\-.]/g, '')); + output = Number(output); // Run the user-specified post-decoder. if ( decoder ) {