计算金额是否小于总金额,大于是不能保存

function kpjejs(oInput){
var result = 0;
var vresult = "kpsq_kpzje";//开票总金额
var wkje = "kpsq_dbhtwkpje"//合同未开票金额 var xh = $("input[name='inputline_kpsqmx_num']").val();//总条数
xh = xh - 1;
for(xh; xh >= 0; xh--){
var dj = xh + "_kpsqmx_dj";//单价
var sl = xh + "_kpsqmx_sl"//数量 var dbdj = $("input[name='" + dj + "']").val();
var dbsl = $("input[name='" + sl + "']").val();
var dbwkje = $("input[name='" + wkje + "']").val(); if(typeof(dbdj)==="undefined"){
dbdj = 0;
}
if(typeof(dbsl)==="undefined"){
dbsl = 0;
} if(xh >= 0){
result = result + dbdj * dbsl;//总金额
$("input[name='" + vresult + "']").val(result);
if(dbwkje < result){
alert("开票金额不能大于合同未开票金额!请重新填写!");
$("input[name='" + dj + "']").val("");
$("input[name='" + sl + "']").val("");
break;
}
}
}
}
function htdjjs(oInput){

    var xh = $("input[name='inputline_hemx_num']").val();//总条数
xh = xh - 1;
for(xh; xh >= 0; xh--){
var htdj = xh + "_hemx_dbprice";//合同单价
var bjdj = xh + "_hemx_dbbjdj";//报价单价 var dbhtdj = $("input[name='" + htdj + "']").val();
var dbbjdj = $("input[name='" + bjdj + "']").val(); if(xh >= 0){
if(parseInt(dbbjdj) > parseInt(dbhtdj) && dbbjdj != ""){
alert("合同单价不能小于报价单价!请重新填写!");
$("input[name='" + htdj + "']").val("");
break;
}
}
}
}

function htdjjs(oInput){
var xh = $("input[name='inputline_hemx_num']").val();//总条数xh = xh - 1;for(xh; xh >= 0; xh--){var htdj = xh + "_hemx_dbprice";//合同单价var bjdj = xh + "_hemx_dbbjdj";//报价单价
var dbhtdj = $("input[name='" + htdj + "']").val();var dbbjdj = $("input[name='" + bjdj + "']").val();if(xh >= 0){if(parseInt(dbbjdj) > parseInt(dbhtdj) && dbbjdj != ""){alert("合同单价不能小于报价单价!请重新填写!");$("input[name='" + htdj + "']").val("");break;}}}}

05-11 09:42