I have a form which checks for the ifsc code of before form submission, The api returns "failure" if wrong ifsc is given. If the response is a failure, the form shouldn't be submitted. I used e.preventDefault(e)
but it didn't help.
$('#corporate-signup').on('submit',function(e){
var ifsc_code = $('#ifsc-code').val();
var api_url = 'http://api.techm.co.in/api/v1/ifsc/'+ifsc_code;
$.get(api_url, function(data, status){
if (data.status === "failure") {
$('.bank-details').addClass('no-ifsc').text(data.message);
e.preventDefault(e);
}
else{
$('#corporate-signup').submit()
}
});
});
I don't know what is the mistake here. I have also tried to return false
instead of preventDefault()
but even it didn't work.