Good afternoon, I have a form, it has a text field that triggers the event .blur that takes the name entered and returns an id with ajax, takes the id saved in another input hidden, the problem is that the event only blur is triggered if I click empty place (to lose the focus) and then the submit button, if I click directly on the submit the blur event is not triggered, any solution to such a problem? I already tried switching to event change but it also did not work if I directly clicked on submit.
$("#responsavel").blur(function(){var cdgResp = $("#responsavel").val();$.post("controller/responsavel.php", {nomeResponsavel:cdgResp} , function(idResp) {if (idResp != false){$("#idResponsavel").val(idResp); }else { $("#idResponsavel").val("0"); } });});
above is the javascript that fires blur
<form action="javascript:func()" method="post">action="javascript:func()" method="post"><input id="responsavel" type="text" name="responsavel" value=<?php echo $dados['responsavel']; ?>"><input id="idResponsavel" type="hidden" name="idResponsavel" value="<?php echo $dados['idResponsavel']; ?>"><input type="submit" value="enviar"></form>
and above this the form, I have now created a generic form to better exemplify, the data is already filled with php but if you change the name of the field responsible would have to change the id of it.