isnan() 函数也接受 .(点)。如何预防它们。这是示例代码:
var Price = $("#Price").val();
if (Price == "") {
alert ("Required!");
}
else if (isNaN(Price)) {
$("#Price").val(Price);
alert("Enter digits");
}
我在文本框的 KeyUp 事件中调用此 JS 代码。
最佳答案
else if (!/^\d+$/.test(Price)) {
// only digits
}
关于javascript - isnan 函数接受点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16727620/