我正在尝试限制我的用户输入以符合 999.99
我正在使用此代码尝试排除第二个小数点的输入,但它不起作用。谁能帮我解决这个问题?
jQuery(".textr2").live('input', function (event) {
var str = jQuery(this).val();
alert(str);
if (str.search('.')) {
alert("Finds a dot");
jQuery(this).val(jQuery(this).val().replace(/[^0-9]/g, ''));
}
else {
alert("NO Dot");
jQuery(this).val(jQuery(this).val().replace(/[^0-9\.]/g, ''));
});