永远不要输入数量超过股票的价值 [英] never enter the value in quantity more than Stock
本文介绍了永远不要输入数量超过股票的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai我使用三个文本框项目,价格和数量,以及一个标签库存,该库存正在绑定数据库中的值。现在我需要用户永远不要输入数量超过库存的值,下面是我的jquery可以任何人请告诉我我想在哪里更改jquery中的代码.Below代码工作正常。
Hai I am using three text boxes Item, Price, and Quantity, and one label stock , the stock are binding the value from the database. Now I need for the User never enter the value for Quantity more than Stock, below is my jquery can anyone Please tell me where I want change the Code in jquery .Below code is working fine .
$(function () {
$("[id*=txtQuantity]").val("0");
});
$("[id*=txtQuantity]").live("change", function () {
if (isNaN(parseInt($(this).val()))) {
$(this).val('0');
} else {
$(this).val(parseInt($(this).val()).toString());
}
});
$("[id*=txtQuantity]").live("keyup", function () {
if (!jQuery.trim($(this).val()) == '') {
if (!isNaN(parseFloat($(this).val()))) {
var row = $(this).closest("tr");
$("[id*=lblTotal]", row).html(parseFloat($(".price", row).html()) * parseFloat($(this).val()));
}
} else {
$(this).val('');
}
var grandTotal = 0;
$("[id*=lblTotal]").each(function () {
grandTotal = grandTotal + parseFloat($(this).html());
});
$("[id*=lblGrandTotal]").html(grandTotal.toString());
});
推荐答案
(function(){
(function () {
( [id * = txtQuantity])。val( 0);
});
("[id*=txtQuantity]").val("0"); });
( [id * = txtQuantity])。live( 更改,function(){
if (isNaN(parseInt(
("[id*=txtQuantity]").live("change", function () { if (isNaN(parseInt(
这篇关于永远不要输入数量超过股票的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文