diff --git a/type-detection/currency.js b/type-detection/currency.js index dd6efc8..bed22e4 100644 --- a/type-detection/currency.js +++ b/type-detection/currency.js @@ -8,27 +8,27 @@ * @author Allan Jardine, Nuno Gomes */ +(function(){ + +// Change this list to the valid characters you want +var validChars = "$£€c" + "0123456789" + ".-,'"; + +// Init the regex just once for speed - it is "closure locked" +var + str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex( validChars ), + re = new RegExp('[^'+str+']'); + + jQuery.fn.dataTableExt.aTypes.unshift( - function ( sData ) + function ( data ) { - var sValidChars = "0123456789.-,"; - var sValidSymbols = "$£€"; - var c; - var symbolMatch = false; - - if ( sValidSymbols.indexOf( sData.charAt(0) ) === -1 ) { + if ( typeof data !== 'string' || re.test(data) ) { return null; } - for ( i=1 ; i