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

289
Views
Is it possible to toggle classList of the form that also has addeventlistener on?

I don’t really have a code snippet, I just thought about it and tried this, but it didn’t work

const checkUserEmail = function (e) {
  const regex =
    /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/;
  e.preventDefault();
  if (!regex.test(inputEmail.value)) {
    this.classList.toggle(".error");
  } else {
    return (inputEmail.value = "");
  }
};

form.addEventListener("submit", checkUserEmail, false);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Remove dot . in the class name:

form.classList.toggle("error")

This should work just fine.

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!