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

159
Views
trying to fix form validation

i'll try to make form validation by giving the background colour and focus to each input when input is empty but, it turns out even though i fill the input, it still focus on the first input. It is not continue to check on the next input

I have tried with this code

    var fName=document.getElementById("in_fName");
    var lName=document.getElementById("in_lName");

//first name validation
        if (fName.innerHTML===""){
            alert("he");
            fName.style.background="#DE8971";
            fName.style.color="#FFE9D6";
            fName.focus();
        } else {
            alert("here");            
            fName.style.background="white";
            fName.style.color="black";
            return false;
        }

       //last name validation
       if (lName.innerHTML===""){
             lName.style.background="#DE8971";
             lName.style.color="#FFE9D6";
            lName.focus();
        }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Why not use require fields in the html section. By doing that you will not have to check for validation in JavaScript.

It would be better if you could also share your html code.

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!