I am doing api call when user enter 6 digit pincode in this condition city and state textfield autofill according to pincode.
My problem is that if I enter 6 digit pincode than it called api but while I edit text box(doing nothing just press arrow key and other key but textfield data is same means no edit) it is calling api every time if i press any button.
So I need to stop api call every time if i m not going to edit pincode
var pin = $("input[name='postcode']").val();
var remText = pin.replace(/ /g, "");
var chk_pin = /^[0-9\s]*$/.test(remText);
console.log(chk_pin + ' ' + chk_pin.length);
openLoader();
$("input[name='city']").val('');
$("select[name='id_state']").val('');
if(remText.length==6 && chk_pin){
getbypostcode(pin);
} else {
$('#pincode-err1').remove();
$('#pincode-err2').remove();
$('#pincode-err3').remove();
$(".postcode").append("<span id='pincode-err2' style='color: #FF8C00'>" + checkPin + "</span>");
closeLoader();
}
});