Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test if string is Integer with Jquery

what is the function which test if a string is an Integer or not like the method :

jQuery.isNumeric()

i want to test an input html element :

<input id='distance' type='text' />

thank you in advance

like image 789
Bouraoui KACEM Avatar asked Sep 11 '14 13:09

Bouraoui KACEM


1 Answers

thank you for your contributions i found the answer :

if(Math.floor($('#distance').val()) == $('#distance').val() && $.isNumeric($('#distance').val()))
 { 
 alert('yes its an int!');
 } 
like image 92
Bouraoui KACEM Avatar answered Oct 13 '22 17:10

Bouraoui KACEM