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

97
Vistas
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 Respuestas
Responde la pregunta

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 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