function checkNum(e) { var re = /^\d+(?=\.{0,1}\d+$|$)/ if (e.value != "") { if (!re.test(e.value)) { alert("请输入正确的数字"); e.value = ""; e.focus(); } } e.value = parseFloat(e.value).toFixed(1); } <input style="width:50px" id="txtDelayDeduction" onblur="checkNum(this)" onkeyup="this.value=this.value.replace(/[^0-9.]/g,‘‘)" type="textbox">
function checkNum(e) {
var re =
/^\d+(?=\.{0,1}\d+$|$)/
if (e.value != "") {
if
(!re.test(e.value)) {
alert("请输入正确的数字");
e.value = "";
e.focus();
}
}
e.value = parseFloat(e.value).toFixed(1);
}
<input style="width:50px" id="txtDelayDeduction" onblur="checkNum(this)"
onkeyup="this.value=this.value.replace(/[^0-9.]/g,‘‘)" type="textbox">
时间: 2024-10-14 14:16:10