NaN值始终从javascript返回

时间:2016-10-25 04:56:23

标签: javascript html

  var s = parseFloat(txtTotal.value, 10);
if (isNaN(s) || txtTotal.value == 0) {
    fncAlert("Please enter amount greater than 0");
    return false;
} 

以上代码始终是RETURNING S AS NaN。任何帮助?

1 个答案:

答案 0 :(得分:1)

您的代码应如下所示,因为您在 txtTotal 中获取价值 变量

首先删除toUpperCase(),然后使用:

var txtTotal = $("#txtNet").val();
var s = parseFloat(txtTotal, 10);
if (isNaN(s) || txtTotal == 0) {
   fncAlert("Please enter amount greater than 0");
   return false;
}