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

212
Views
How to sense a particular letter in user input in JS

If I type something with the letter 1 it should redirect to another page for eg: 1sometxt.
if not it should redirect to another page

function functionclick() {
     var input = document.getElementById("myInput").value;
     var input1 = "1";
     if (input === input1 + i dont know what to give here ) {
         window.open("www.example.com");
     }else {
window.open("www.example.com");
}
 }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

document.getElementById("myInput").addEventListener("change"), (e)=>{

     var input = e.target.value
    
     if (input.includes(1) ) {
         window.open("www.example.com");
     }else {
         window.open("www.example.com");
     }
}
about 4 years ago · Juan Pablo Isaza Report

0

You can check if input contain '1' by using input.includes('1'), or if '1' should be the first character the if condition could be something like this

if(input[0] === input1) { // doesn't matter what next characters are, check if input first character equal to input1 variable
  // your code here
}
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!