Categories

jQuery.isNumeric()

Categories: Utilities

jQuery.isNumeric( value )Returns: Boolean

Description: Determines whether its argument is a number.

  • jQuery.isNumeric( value )

    version added: 1.1

    value   The value to be tested.

The $.isNumeric() method checks whether its argument represents a numeric value. If so, it returns true. Otherwise it returns false. The argument can be of any type.

  • Sample return values of $.isNumeric with various inputs.

    Code:
    
    $.isNumeric("-10");  // true
    $.isNumeric(16);     // true
    $.isNumeric(0xFF);   // true
    $.isNumeric("0xFF"); // true
    $.isNumeric("8e5");  // true (exponential notation string)
    $.isNumeric(3.1415); // true
    $.isNumeric(+10);    // true
    $.isNumeric(0144);   // true (octal integer literal)
    $.isNumeric("");     // false
    $.isNumeric({});     // false (empty object)
    $.isNumeric(NaN);    // false
    $.isNumeric(null);   // false
    $.isNumeric(true);   // false
    $.isNumeric(Infinity); // false
    $.isNumeric(undefined); // false