开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜