function coupon_check_plan() {
if (document.getElementById('r5').checked) {
var ret = false;
var coupon = $("#coupon").val();
if (coupon == "") {
ret = false
$("#er3").html('<img src="' + img_loc + 'cross.png"/> Cannot be left blank');
}
if (coupon != "") {
$.post("coupon_check.php", {
"coupon": coupon
}, function (data) {
if (data.result == "0") {
ret = false;
$("#er3").html('<img src="' + img_loc + 'cross.png"/> This Code is aready used');
}
if (data.result == "-1") {
ret = false;
$("#er3").html('<img src="' + img_loc + 'cross.png"/> This Code is invalid');
}
if (data.result == "1") {
$("#frmsup1").submit();
}
});
}
} else {
}
return ret;
}
<form action="sbs_check2.php" method="POST" id="frmsup1" onsubmit="return coupon_check_plan();" >
<input type="radio" name="package" value="Coupon" id="r5" checked="true" onclick="choose()" />
<input type="text" name="coupon" id="coupon" onfocus="document.getElementById('er3').innerHTML='';" placeholder="Enter Coupon Code" style="margin-top:10px;"/>
<div class="err" id="er3"></div>
<input type="radio" name="package" value="Free" id="r1" onclick="choose()" />
<input type="radio" name="package" value="bronze" id="r2" onclick="choose()" />
<input type="submit" name="submit" value="Register Now" class="submitbut2" id="pur">
</form>
When I click on the submit button, if the the radio button with id r5 is clicked then with id coupon is send an ajax request to check wether the coupon is valid or not and if ajax result give a 1 then it will submit the form but like a loop it is sending the request and the result is 1 only but it is not submittng the form.