Jquery, validate a Post call within a block .submit

0

I am trying to validate in a submit block with a post call in which I consult a web service, and depending on the result I allow the submit or not, but it never enters the post function and makes the submit automatically.

this is the code

$(document).off('submit','#formulario_preregistro',function(event)
{
  event.stopPropagation();
  numeroSerie=$("#serie_valida").val();


$.post("chws.php", {Serie:numeroSerie}, function(valid)
  {
     alert(valid);

    if (valid == 1 || valid == 2)
    {
     return true;   
    }
    else
    { 
     alert('EL NuMERO DE SERIE DE SU PRODUCTO ES INVaLIDO');
     event.stopPropagation();
    }
 });


});
    
asked by Ricardo 03.03.2018 в 22:44
source

0 answers