Check a value is float or int in jQuery

By | July 26, 2015

Check a value is float or int in jQuery

Handling numbers in input boxes is quiet easy when using jQuery. It is much is easy to validate whether a entered value is number or not, also to check a value is float or int in jQuery.

Let’s see how we can do this in jQuery,

To check a value is number or not, we can use typeof() function.

The “typeof” operator is a javascript operator which allows you to find the data type of its operand, such as whether a variable is string, numeric, or undefined.

The above function will find whether the entered value is a number or not.

To check a value is float or int in jQuery, we can use the below line added to the above code in order validate the number first and then to check float or int.

Combining all as a single code

Leave a Reply