Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!