我只允许这样的数字:
有人能帮我吗?我只能用这种方式限制int:
$('#valueSconto').on('input', function () {
this.value = this.value.replace(/[^0-9]/g, '');
});发布于 2015-06-21 15:44:32
尝试将input maxlength设置为5;利用.val(function(index, val));RegExp /\d{3}|[^\d{2}\.]|^\./
$("#valueSconto").on("input", function() {
$(this).val(function(i, val) {
return val.replace(/\d{3}|[^\d{2}\.]|^\./g, "");
});
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<input type="text" id="valueSconto" maxlength="5" />
https://stackoverflow.com/questions/30965201
复制相似问题