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

139
Views
HTML .value checking not working properly

I have been working on a little coding project for my friends. This includes a somewhat password system that changes your username. I implemented this so that impersonation was harder to do.

<main class="join-main">
    <label for="password">Password</label>
    <input type="password" name="password" id="password" placeholder="Enter password..." required />
    <button type="button" onclick="fn1()">Check ig</button>
    <script>
        function fn1() {
            let pswvalue = document.getElementById("password").value

            if (pswvalue = "1234") {
                document.getElementById("username").value = "Hello"
            } else {
                return;
            }
        }
    </script>
    <form action="chat.html">
      <div class="form-control">
        <label for="username">Logging Into:</label>
        <input
          type="text"
          name="username"
          id="username"
          placeholder="The User you are logging into will appear here." 
          readonly
        />
      </div>
    </form>

For some reason, even if the password isn't "1234", The username still changes to Hello. Any suggestions on how to fix it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It should be if (pswvalue === "1234") since we are comparing two stings.

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!