In the past, there’s been so many times I needed to tell if an object was numeric. With the below function, it’s very easy to tell if an item is numeric.
//return false if blank, null, undefined or NaN. function isNumeric(v) { if (v == null || v == undefined || v== '') { return false; } return !isNaN(v) && isFinite(v); }
If your project is already using jQuery, you could always use jQuery.IsNumeric()