Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery.isNumeric() method

jQuery.isNumeric() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods

Example

Determine the type of the input value

$

(

function

(

)

{

function

fun

(

html

)

{

document

.

body

.

innerHTML

+=

"


"

html

;

}

//

true

fun

(

$.

isNumeric

(

"

-10

"

)

)

;

fun

(

$.

isNumeric

(

"

0

"

)

)

;

fun

(

$.

isNumeric

(

0x

FF

)

)

;

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

)

)

;

}

)

Try it »


Definition and Usage

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

**Note:** In jQuery 3.0, the $.isNumeric() method returns true only when it receives an argument of type number, or an argument of type string that can be coerced to a finite number; otherwise it returns false.


Syntax

$

.isNumeric( value )

Parameters Description
value Any type: The arbitrary value to be checked.

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods