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()
Author: Brian Cline
Brian is a programmer living in Niagara Falls with ten years of development experience. He is passionate about automation, business process re-engineering, and gamification. For the last six years or so, he has been working with Salesforce and JavaScript.