Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

625
Vistas
Submit form with JS after captcha validation

I've just included the sections I thought were relevant. I would like the form to submit once the JS validates Captcha. But it never goes to the next page. What am I missing?

<body>
<div class="wrapper">
    <header>Captcha in JavaScript</header>
    <div class="captcha-area">
      <div class="captcha-img">
        <img src="captcha-bg.png" alt="Captch Background">
        <span class="captcha"></span>
      </div>
      <button class="reload-btn"><i class="fas fa-redo-alt"></i></button>
    </div>
    <form name:"myform" action="checkout5.php" class="input-area" method="post">
      <input type="text" placeholder="Enter captcha" maxlength="6" spellcheck="false" required>
      <button type:"submit" value="submit" class="check-btn">Submit</button>
    </form>
    <div class="status-text"></div>
  </div>
  <script src="script.js"></script>
</body>
<script>
checkBtn.addEventListener("click", e =>{
  e.preventDefault(); //preventing button from it's default behaviour
  statusTxt.style.display = "block";
 let inputVal = inputField.value.split('').join(' ');
  if(inputVal == captcha.innerText){ //if captcha matched
        statusTxt.style.color = "#4db2ec";
        statusTxt.innerText = "Nice! You don't appear to be a robot.";
        setTimeout(()=>{ //calling removeContent & getCaptcha after 2 seconds
        removeContent();
        getCaptcha();
        }, 2000);
  }else{
    statusTxt.style.color = "#ff0000";
    statusTxt.innerText = "Captcha not matched. Please try again!";
  }
});

</script>
</html>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can validate your Captcha on server side (this ex Django).

            # Get Captcha Response
            captcha_response = request.POST['g-recaptcha-response']

            # Get Google Recaptcha Secret key
            secret_key = settings.GOOGLE_RECAPTCHA_SECRET_KEY

            # Captcha Payload
            captcha_payload = {
                'secret': secret_key,
                'response': captcha_response
            }

            # Verify Captcha Response
            captcha_verify = requests.post(
                "https://www.google.com/recaptcha/api/siteverify", data=captcha_payload).json()

            # Check if Captcha not Success
            if not captcha_verify['success']:
                return JsonResponse({"error": "Invalid reCAPTCHA Please try again..."}, status=400)
            else:
                #your after validate code
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda