正则表达式为浮点值 [英] regular expression for floating point value
本文介绍了正则表达式为浮点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I want my textbox to have only floating point value, and filter out any symbols and alphabetical letters, the nearest solution i found is:
jQuery(".sow-items .discovery_repeat input.hours").live("keyup", function(e) {
$(this).val($(this).val().replace(/[^\d]/, ''));
});
但它也过滤出小数点。如何从上面的过滤器中排除小数或者任何新的建议?
but it also filters out decimal point. how to exclude decimal from the above filter or any new suggestions?
推荐答案
试试这个:
Try this:
jQuery(".sow-items .discovery_repeat input.hours").live("keyup", function(e) {
$(this).val($(this).val().replace(/[^\d.]/g, ''));
});
这篇关于正则表达式为浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文