isNumeric(value, strict)
JavaScript
log('num1: ' + isNumeric('E'));
log('num2: ' + isNumeric(-1));
log('num3: ' + isNumeric(0));
log('num4: ' + isNumeric(0.42));
log('num5: ' + isNumeric(0,42));
log('num6: ' + isNumeric(.42));
log('num7: ' + isNumeric(1));
log('num8: ' + isNumeric(123));
log('num9: ' + isNumeric(99,999));
log('num10: ' + isNumeric('-1'));
log('num11: ' + isNumeric('0'));
log('num12: ' + isNumeric('1'));
log('num13: ' + isNumeric('123'));
log('num14: ' + isNumeric(-1, true));
log('num15: ' + isNumeric(0, true));
log('num16: ' + isNumeric(1, true));
log('num17: ' + isNumeric(123, true));
log('1: ' + isNumeric('-1', true));
log('2: ' + isNumeric('0', true));
log('3: ' + isNumeric('1', true));
log('4: ' + isNumeric('123', true));
log('5: ' + isNumeric('abc'));
log('6: ' + isNumeric(123 + 'abc'));
log('7: ' + isNumeric('123abc'));
log('8: ' + isNumeric('abc', true));
log('9: ' + isNumeric(123 + 'abc', true));
log('10: ' + isNumeric('123abc', true));
log('other1: ' + isNumeric(true));
log('other2: ' + isNumeric(true, true));
log('other3: ' + isNumeric(false));
log('other4: ' + isNumeric(false, true));
log('other5: ' + isNumeric(null));
log('other6: ' + isNumeric(null, true));
log('other7: ' + isNumeric(undefined));
log('other8: ' + isNumeric(undefined, true));
log('other9: ' + isNumeric(''));
log('other10: ' + isNumeric('', true));
log('other11: ' + isNumeric(' '));
log('other12: ' + isNumeric(' ', true));
function isNumeric(value, strict)
{
var strict = (typeof strict == 'undefined' ? false : (strict == true ? true : false));
if(strict && typeof value != 'number') {
return false;
}
return !isNaN(parseFloat(value)) && isFinite(value);
}
function log(value)
{
$('body').append(value + '<br>');
}