JavaScript IsNumeric Function

Sharing is Caring

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()

Sharing is Caring

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.