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

99
Visualizações
text box that goes to website when answer is correct

I need the user to type a word and if its the right keyword, I need it to change pages.

my code

<form action="/yay.html">
    <label>what's 1+1</label><br>
    <input type="text"><br>
    <input type="submit" value="Submit">
</form>

for example I want something a bit like this.

<script>
function checkstuff() {
if text = "hello world" 
}
</script>
//so a function checks if the text is equal to "hello world"

<form action="/yay.html">
    <input type="text">
    <input type="submit" value="Submit" onclick="checkstuff()">
    //submit input runs function
</form>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In the solution below, the user input is evaluated to enable/disable the disabled attribute of the submit button.

const submit = document.getElementById('submit');
let answer = document.getElementById('answer');
const target = 2;

function log(value, mode) {
  console.clear();
  
  if(mode)
    console.log(`Information: ${value}`);
  else
    console.log(`Input: ${value}`);
}

answer.addEventListener('input', function(event) {
  log(this.value, true);
  
  if(parseInt(this.value) == target) {
    submit.disabled = false;
  }
  else {
    submit.disabled = true; 
  }
});

submit.addEventListener('click', function(event) {
  log("Button fired.", false);
});
<form action="/yay.html">
    <label>what's 1+1</label><br>
    <input id="answer" type="text"><br>
    <input id="submit" type="submit" value="Submit" disabled>
</form>

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