1
Well, I have a function(1) with validations in js, I would like to call it within another function(2) js and if and function one has a result, I would like to stop the execution of function 2 For example:
function validarCamposSimulador() {
if (form_alterar.opcoes.value == "Selecione...") {
alert("Selecione um Tipo de Empréstimo!");
form_alterar.opcoes.focus();
return false;
}
if (form_alterar.salario_bruto.value == "0,00" || form_alterar.salario_bruto.value == "") {
alert("Digite seu Salário Bruto");
form_alterar.salario_bruto.focus();
return false;
}
if (form_alterar.desconto.value == "") {
alert("Digite um Desconto");
form_alterar.desconto.focus();
return false;
}
if (form_alterar.salario_liquido.value == "0,00" || form_alterar.salario_liquido.value == "") {
alert("Digite seu Salário Liquido");
form_alterar.salario_liquido.focus();
return false;
}
if (form_alterar.valor_sol.value == "0,00" || form_alterar.valor_sol.value == "") {
alert("Digite o Valor a ser Solicitado");
form_alterar.valor_sol.focus();
return false;
}
}
Now within that function I would like to call the previous
$("#btn_emp").click(function(){
var valor_maximo = $("#val_max").val();
var valor_sol = $("#valor_sol").val();
var valor_entrada = $("#valor_entrada").val();
var data_inicio = $("#data_inicio").val();
var prazo = $("#prazo").val();
data_inicio = data_inicio.replace("/", "-");
data_inicio = data_inicio.replace("/", "-");
var auxiliar;
$.ajax({
method: "GET",
url: "../calcularEmprestimo.asp",
data: { v_sol: valor_sol, v_ent: valor_entrada, prz: prazo, val_max: valor_max, dt_ini: data_inicio },
success: function(response) {
document.getElementById("parcela_inicial").value = response;
}
});
I added an answer too. I saw your Dit but I couldn’t figure out which function to call which... you want to call
validarCamposSimulador
inside the callback of theclick
and stop if it doesn’t work, that’s it?– Sergio
Thiago, did any of the answers below solve your problem? If yes you can click to mark as accepted. If it does not say, to explain better.
– Sergio