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

123
Views
on click the result appears then auto refreshes

document.querySelector('.login').addEventListener('click', function() {
  const check = document.querySelector('.username').value;
  console.log(typeof check);

  if (!check) {
    document.querySelector('.errorMessage').textContent =
      'kindly enter your username';
  }
});
<div class="user-login">
  <form>
    <label for="">User Name :  <input type="text" name="userName" class=" username"></label> <br>
    <label for="">Password:  <input type="password" name="" class="password"></label> <br>
    <button class="login">Login</button>
  </form>
</div>

<div class="errorMessage">
  <label for=""></label> <br>
</div>

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

0

To your html modify the button like this:

<button type="button" class="login">Login</button>

or in your javascript you can do something like this:

document.querySelector('.login').addEventListener('click', function(e) {
    e.preventDefault(); // Add this after set 'e' as parameter
    const check = document.querySelector('.username').value;
    console.log(typeof check);

    if (!check) {
       document.querySelector('.errorMessage').textContent =
       'kindly enter your username';
    }
});
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!