I have series of textboxes i want on change function at the last textbox.i have tired as follows,
<div id="filterMeasurement" class="col-md-4 col-sm-6 col-xs-12 filterControls" style="display: none;">
<h4>Measurements in (mm)</h4>
<div class="mea-bx">
<h5>Length </h5>
<div>
<input name="txtLengthFrom" type="text" id="txtLengthFrom" class="textSmLeft" placeholder="from" />
<input name="txtLengthTo" type="text" id="txtLengthTo" class="textSmRight" placeholder="to" />
</div>
</div>
<div class="mea-bx">
<h5>Width </h5>
<div>
<input name="txtWidthFrom" type="text" id="txtWidthFrom" class="textSmLeft" placeholder="from" />
<input name="txtWidthTo" type="text" id="txtWidthTo" class="textSmRight" placeholder="to" />
</div>
</div>
<div class="mea-bx">
<h5>Height </h5>
<div>
<input name="txtHeightFrom" type="text" id="txtHeightFrom" class="textSmLeft" placeholder="from" />
<input name="txtHeightTo" type="text" id="txtHeightTo" class="textSmRight" placeholder="to" />
</div>
</div>
</div>
jQuery:
$("#filterMeasurement").find('input[type=text]').change(function () {
var lengthfrom = $("#txtLengthFrom").val();
var lengthto = $("#txtLengthTo").val();
var widthfrom = $("#txtWidthFrom").val();
var widthto = $("#txtWidthTo").val();
var heightfrom = $("#txtHeightFrom").val();
var heightto = $("#txtHeightTo").val();
if (lengthfrom != '' && lengthto != '' && widthfrom != '' && widthto != '' && heightfrom != '' && heightto != '') {
UpdateGrid();
}
else {alert("Fill all the fields")}
});
Here for each textbox on change throwing alert in else block.How can i get alert only on last textbox on change by checking all textboxes as mandatory?
Can anyone please help me out??
Thanks in advance.