I have this function, but the return does not work on it, I do not want it to get out of it as long as it does not fit the function:
if ($('#FreteComprador').prop("checked") == true) {
var id = $("#idtransportador").val();
var frete = $("#Frete").val();
if (id == "") {
alert("Preencha o campo transportador corretamente.");
return;
} else {
var url = "/PedidoFornecedor/VerificaCNPJ";
$.ajax({
url: url
, data: { id: id }
, type: "POST"
, datatype: "html"
, success: function (data) {
if (data.resultado == true && frete == "0,00") {
alert("É obrigatório preencher o valor do frete.");
return;
}
}
});
}
}
How can I do it? In other ifs, when I put return
it works, in it it exits the function.