Reputation: 843
How to only allow decimals numbers in a Input Ej:
12.00,
12.44,
00.34
Many Thanks
Upvotes: 1
Views: 509
Reputation: 32716
Here:
var isFloat = function(n) {
return n % 1 !== 0;
}
So you could do:
if(isFloat(n)){
//Do something
}
else{
//Give an error
}
Upvotes: 1