jQuery.isNumeric()S2C Home « Utilities « jQuery.isNumeric()

Numeric value detection.

Description

The jQuery.isNumeric() jQuery Type utility method, returns a boolean dependant upon the specified value being numeric.

Shorthand version $.isNumeric()

  • Returns true for numeric values.

Syntax


Signature Description
jQuery.isNumeric( value )Return a boolean dependant upon the specified value being numeric.

Parameters


Parameter Description Type
value The value to test to see if it is numeric.PlainObject

Return

A Boolean object.

jQuery.isNumeric( value ) Examplego to top of page Top

Return a boolean dependant upon the specified value being numeric.

In the example below when we press the button we test some values to see if they are numeric.


$(function(){
  $('#btn3').one('click', function(){
    $('#div3').append('Is null numeric? ' +  $.isNumeric(null) + '<br />');
    $('#div3').append('Is undefined numeric? ' +  $.isNumeric(undefined) + '<br />');
    $('#div3').append('Is "a" numeric? ' +  $.isNumeric("a") + '<br />');
    $('#div3').append('Is "-1" numeric? ' +  $.isNumeric("-1") + '<br />');
    $('#div3').append('Is -1 numeric? ' +  $.isNumeric(-1) + '<br />');
    $('#div3').append('Is +1 numeric? ' +  $.isNumeric(-1) + '<br />');
    $('#div3').append('Is 1.23 numeric? ' +  $.isNumeric(1.23) + '<br />');
    $('#div3').append('Is "1.6456456456e+1?" ' +  $.isNumeric("1.6456456456e+1") + '<br />');
    $('#div3').append('Is "0x00" numeric? ' +  $.isNumeric("0x00") + '<br />');
    $('#div3').append('Is false numeric? ' +  $.isNumeric(false) + '<br />');
    $('#div3').append('Is true numeric? ' +  $.isNumeric(true) + '<br />');
    $('#div3').append('Is NaN numeric? ' +  $.isNumeric(NaN) + '<br />');
    $('#div3').append('Is Infinity numeric? ' +  $.isNumeric(Infinity) + '<br />');
  });
});

div3. Some initial text.

Press the button below to action the above code:


go to home page Homepage go to top of page Top