diff --git a/sorting/datetime-moment.js b/sorting/datetime-moment.js index aae10d9..13b05b1 100644 --- a/sorting/datetime-moment.js +++ b/sorting/datetime-moment.js @@ -27,12 +27,17 @@ $.fn.dataTable.moment = function ( format, locale ) { // Add type detection types.detect.unshift( function ( d ) { + // Strip HTML tags if possible + if ( d && d.replace ) { + d = d.replace(/<.*?>/g, '') ) { + } + // Null and empty values are acceptable if ( d === '' || d === null ) { return 'moment-'+format; } - return moment( d.replace ? d.replace(/<.*?>/g, '') : d, format, locale, true ).isValid() ? + return moment( d, format, locale, true ).isValid() ? 'moment-'+format : null; } );