Only Accept Numbers with Decimal in a Input Using Javascript?
How to only allow decimals numbers in a Input Ej:
12.00,
12.44,
00.34
开发者_如何学Go
Many Thanks
Here:
var isFloat = function(n) {
return n % 1 !== 0;
}
http://jsbin.com/iwitep/edit
So you could do:
if(isFloat(n)){
//Do something
}
else{
//Give an error
}
精彩评论