<input name="QtyFail" date-name="Property_QtyFail" onchange="changeBadNumber(this)" class="inputbox" style="width:50px;" value="@(inspectionDetail.BadQty)" disabled />
var inupt_QtyFail = $("input[date-name='Property_QtyFail']");
inupt_QtyFail[0].value;
function changeBadNumber(that) {
var value = $(that).val();
if (value == "") {
return false;
}
var badAcceptanceQty = parseInt($(that).parent().parent().find("td[name='BadAcceptance']").text());
var badRejectionQty = parseInt($(that).parent().parent().find("td[name='BadRejection']").text());
var inspectionQty = $(that).parent().parent().find("td[name='SamplingSize']").text();
var qualifiedQty = parseInt(inspectionQty) - parseInt(value);
if (qualifiedQty < 0) {
$(that).parent().parent().find("td[name='QualifiedQty']").find('input').val('0');
}
else {
$(that).parent().parent().find("td[name='QualifiedQty']").find('input').val(qualifiedQty);
}
if (value <= badAcceptanceQty) {
$(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').val('@Html.Raw(Label.Pass)');
$(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').change();
}
else {
$(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').val('@Html.Raw(Label.Failure)');
$(that).parent().parent().find("td[name='InspectionSectionConclusion']").find('input').change();
}
}
<input id="txt" data-type="GroupAttr" data="@(inspectionDetail.GroupAttr)" name="@inspectionDetail.GroupName" CodeName="@detail.InspectionItems.CodeName" iscollect="N" value="@(inspectionCollectionDetail.Count == 0 ? " " : inspectionCollectionDetail.First().InspectionValue)" UpperLimit="@detail.InspectionItems.UpperLimit" LowerLimit="@detail.InspectionItems.LowerLimit" class="inputbox" inspectionOrder="@inspectionDetail.SortOrder" itemOrder="@detail.SortOrder" eachCollection="@detail.InspectionItems.EachCollection" onblur="calAnalysis(this)" />
function calAnalysis(that) {
var GroupAttrType = $(that).parent().find("input[data-type='GroupAttr']").attr('data');
if ($(that).val() == "" || GroupAttrType=="@(Const.PERFORMANCEL_INSPECTION)")
{
return;
}
var inspectionName = $(that).attr("CodeName");
var enterValue = parseFloat($(that).val());
var upperValue = parseFloat($(that).parent().find("i[name='upperLimit']").text());
var lowerValue = parseFloat($(that).parent().find("i[name='lowerLimit']").text());
if (enterValue != NaN && enterValue != undefined&&(enterValue > upperValue || enterValue < lowerValue)){
$(that).css('color', 'red');
}
else if (enterValue != NaN && enterValue != undefined && (lowerValue<= enterValue <= upperValue)) {
$(that).css('color', '');
}
}