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

286
Visualizações
la función setTimout() no funciona dentro de la función

Entonces, aquí está la función, cuando coloco la función setTimeout() en la función checkForm , no funciona, también intenté ponerla fuera de la función checkForm y tampoco funciona.

 function checkForm(event) { event.preventDefault(); var name = document.getElementById('username').value; var email = document.getElementById('user-email').value; var message = document.getElementById('message').value; var error = ""; if (name.length == 1 || email.length == 1 || message.length == 1) { error = "Min length of the fields is 2 character." } else if (name == "" || email == "" || message == "") { error = "Fields are empty." } else if (name.length > 15 || email.length > 20 || message.length > 100) { error = "Max length of the fields is 15 charcaters." } if (error == "") { alert("You sucessfully filled up the form."); setTimeout(function () { window.location = "https://www.ebay.com/" }, 5000); } else { document.getElementById('errorDiv').innerHTML = error; } }
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Necesita cambiar a window.location.href = "your link"

 function checkForm(event) { setTimeout(function () { window.location.href = "https://www.ebay.com/"; alert('go to ebay'); }, 2000); }
 <button onclick="checkForm()">Check Form</button>

about 4 years ago · Juan Pablo Isaza Relatório

0

Intenta de esta manera

 setTimeout(function () { location.href = "https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_href_set"; }, 2000);
about 4 years ago · Juan Pablo Isaza Relatório

0

Por casualidad, aparece la alerta y no está reconociendo la ventana emergente y esto está causando que el navegador espere a que usted reconozca la ventana emergente. si ese es el caso, elimine la alerta ("Usted completó con éxito el formulario") y verifique si funciona

about 4 years ago · Juan Pablo Isaza Relatório
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