Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
Prepend token value to html form using js

Am trying to add google recaptcha 3 to my html form. Works find when i call it on page load but due to the fact that it expires after 2mins and should be called when ready, am trying to add it to my submit function but don't know where am doing it wrong.

my js code is:

     <script>
                    
                    
  $(document).ready(function () {
    $('.regformsubmit').click(function (e) {
        
        grecaptcha.execute('6LcVzjYcmykey is here', {action: 'validate_captcha'}).then(function(token) {
                // add token to form
                $("#register_form").prepend('<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response" value="' + token + '">');
        });
              
      var myForm = jQuery( "#register_form" );

  if ( ! myForm[0].checkValidity() )
  {
    // bonk! failed to validate, so return true which lets the
    // browser show native validation messages to the user
    return true;
  }
      e.preventDefault();
      var country = $('#country').val();
      var fname = $('#fname').val();
        var lname = $('#lname').val();
        var emailid = $('#emailid').val();
        var password = $('#password').val();
        var confirm_password = $('#confirm_password').val();
        var phone = $('#phone').val();
        var vcode = $('#vcode').val();
        var upline = $('#upline').val(); 
        var agree_term = $('#agree_term').val(); 
        var cr = $('#g-recaptcha-response').val(); 
      $.ajax
        ({
          type: "POST",
          url: "process-reg.php",
          data: { "country": country,"fname":fname, "lname": lname, "emailid": emailid, "password": password, "confirm_password": confirm_password, "phone": phone, "vcode": vcode, "upline": upline, "agree_term": agree_term, "cr": cr },
          success: function (data) {
            $('#RegResult').html(data);
            $('#register_form')[0].reset();
          }
        });
    });
  });
</script>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda