Jquery Form Validator with id exchange through attr

0

I'm putting together a form that is validated by Jquery Form Validator link

What I am doing is that when I send the form, I validate the fields that I require and if they are correct I send them through ajax, at the end of the query I modify the id of the form and the html of the submit button.

The idea is that in the first shipment I make a query to the BD and it is valid that the data is not already in the database and I show a message indicating if the data is already or not, the user will be able to register the data mentioned, I just need to inform you and this for me would be a second form, so I changed the ID to do a second validation.

the first validation works, the second does not.

My code is this.

<form role="form" id="validar_participante" method="post">

<button class="btn btn-lg btn-info" id="enviar_formulario">Verificar Alumno</button>

To process this form I use this code:

<script>
$.validate({
  form : '#validar_participante',
  modules : 'html5',
  lang : 'es',
validateOnBlur : true,
errorMessagePosition : 'inline', 
scrollToTopOnError : false, 
onSuccess : function($form) {
   var url = "matricula_val_process.php"; 
   $.ajax({
       type: "POST",
       url: url,
       data: $("#validar_participante").serialize(), 
       success: function(data)
       {
           $("#respuesta_proceso").html(data); 
           $("#enviar_formulario").text("Cargar Alumno");
           $("#enviar_formulario").attr('id','reenviar_formulario');
           $("#validar_participante").attr('id','agregar_participante');

       }
   });

return false; 

}, });

This code does the ajax query and returns the necessary information.

Later what I want is to validate the "New form" since I changed the ID and I consider it a new form and I use a new script.

$.validate({
  form : '#agregar_participante',
  modules : 'html5',
  lang : 'es',
validateOnBlur : true, 
errorMessagePosition : 'inline', 
scrollToTopOnError : false, 
onSuccess : function($form) {
   var url = "matricula_add_process.php"; 
   $.ajax({
       type: "POST",
       url: url,
       data: $("#agregar_participante").serialize(), /
       success: function(data)
       {
        $("#respuesta_proceso").hide();
           $("#respuesta_proceso_complete").html(data); 
           $("#reenviar_formulario").hide();

       }
   });

return false; 

}, });

The issue is that this second does not perform the action

Will they have any idea what mistake I'm making?

I am attentive and I appreciate your time.

    
asked by Mauricio Salgado Gonzalez 12.10.2018 в 01:19
source

0 answers