isNaN() 函数通常用于检测 parseFloat() 和 parseInt() 的结果,

以判断它们表示的是否是合法的数字。当然也可以用 isNaN() 函数来检测算数错误,比如用 0 作除数的情况。

 

  var txtCostVal=document.getElementById("txtCost").value;
        if(txtCostVal == "" ||isNaN(txtCostVal)||Number(txtCostVal)== 0) {
            alert("請輸入額外費用!");
            document.getElementById("txtCost").focus();
            return false;
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-09-22
  • 2021-10-01
相关资源
相似解决方案