Easy Tutorial
❮ Misc Deferred Isrejected Event Mouseover ❯

jQuery.isNumeric() Method

jQuery Miscellaneous Methods

Example

Determine the type of input value

$(function () { 
    function fun( html ){ 
        document.body.innerHTML += "<br>" + html; 
    } 
    // true
    fun($.isNumeric( "-10" ));  
    fun($.isNumeric( "0" ));
    fun($.isNumeric( 0xFF ));
    fun($.isNumeric( "0xFF" ));
    fun($.isNumeric( "8e5" ));
    fun($.isNumeric( "3.1415" ));
    fun($.isNumeric( +10 ));
    fun($.isNumeric( 0144  ));
    //false
    fun($.isNumeric( "-0x42" ));  
    fun($.isNumeric( "7.2acdgs" ));
    fun($.isNumeric( "" ));
    fun($.isNumeric( {} ));
    fun($.isNumeric( NaN ));
    fun($.isNumeric( null ));
    fun($.isNumeric( true ));
    fun($.isNumeric( Infinity  ));
    fun($.isNumeric( undefined  ));    
})

Definition and Usage

The $.isNumeric() function is used to determine whether the specified parameter is a numeric value.

Note: In jQuery 3.0, the $.isNumeric() method returns true only if the parameter is of type number or a string that can be coerced into a finite number, otherwise it returns false.


Syntax

Parameter Description
value Any type The arbitrary value to be evaluated.

jQuery Miscellaneous Methods

❮ Misc Deferred Isrejected Event Mouseover ❯