首页 > 解决方案 > number_format 遇到的格式不正确的数值

问题描述

使用数字格式更新发票中的值时,我收到了格式不正确的数值错误消息。

$amount = number_format($_POST['amount'], 2);

标签: phphtml

解决方案


我已更新 JavaScript 以使用 isNaN() 验证金额

 var amount = $('#invoiceAmount').val();
    if(isNaN(amount)){
    alert ('Please enter in the valid amount.');
    } else 
    // post values by AJAX
    }

推荐阅读