JQuery | isNumeric() method

This isNumeric() Method in jQuery is used to determines whether its argument represents a JavaScript number.

Syntax:

jQuery.isNumeric( value )

Parameters: The isNumeric() method accepts only one parameter that is mentioned above and described below:

  • value: This parameter is the value to be tested.

Return Value: It returns the boolean value.

Below examples illustrate the use of isNumeric() method in jQuery:



Example 1: In this example, the isNumeric() method checks an value to see if it’s a numeric.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | isNumeric () method</title
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </h1
      
    <h3>JQuery | isNumeric () method</h3>
    <b>Check the following value are Numeric or not </b>
    <br>
    <p></p>
    <script>
      
    //document.location
    $( "p" ).append("123 : " +$.isNumeric( 123 ) 
                +"<br>" + "0 : " + $.isNumeric( "0" )
                +"<br>" + "0x6F : " +$.isNumeric( "0x6F" )
                +"<br>" + "3e7 : " +$.isNumeric( "3e7" )
                +"<br>" + "3.14 : " +$.isNumeric( "3.14" )
                +"<br>" + "-1 : " + $.isNumeric( -1 ));
      
    </script>
</body>
</html>                                                

chevron_right


Output:

Example 2: In this example, the isNumeric() method also checks an value to see if it’s a numeric.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | isNumeric () method</title
<script src=
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </h1
      
    <h3>JQuery | isNumeric () method</h3>
    <b>Check the following value are Numeric or not </b>
    <br>
    <p></p>
    <script>
      
    //document.location
    $( "p" ).append("undefined  : " +$.isNumeric( undefined  ) 
                +"<br>" + "Infinity  : " + $.isNumeric( "Infinity " )
                +"<br>" + "true  : " +$.isNumeric( "true " )
                +"<br>" + "null  : " +$.isNumeric( "null " )
                +"<br>" + "NaN  : " +$.isNumeric( "NaN " )
                +"<br>" + "-0x42 : " + $.isNumeric( "-0x42" ));
      
    </script>
</body>
</html>                                                                                                

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.