用于检查表单输入数量是否超过mysql数据库中可用数量的Javascript

时间:2016-11-03 15:47:41

标签: javascript php mysql

我想检查文本框输入数量是否超过数据库中purchase_items表中的可用数量。 (我使用php进行编码。)

sales.php的代码片段

function check_qty() {
 var qty=document.getElementById('txtQuantity').value;
 <<code for retrieving "avail_qty" from "purchase_items" table>>
 if(qty>avail_qty) {
     alert("Quantity exceeds.");
    } 
}

<input name="txtQuantity" type="text" id="txtQuantity" size="5" pattern="^[0-9]+$" title="Only numbers are allowed."/>

<button type="button" name="btnSave" id="btnSave" onclick="check_qty();">ADD</button></td>

0 个答案:

没有答案