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

118
Views
Javascript Pin Code Validation add number 0

I'm still pretty new to the whole javascript environment. At the moment I'm trying to add the number 0 to a pin code pad. However, the number 0 is always granted as 10 can someone help me where the error lies?

Here is the link to the code

(function() {
    var input   = "",
        correct = "1593";
    
    var dots    = document.querySelectorAll(".dot"), 
        numbers = document.querySelectorAll(".number");
        dots    = Array.prototype.slice.call(dots);
        numbers = Array.prototype.slice.call(numbers);
    
    numbers.forEach(function(number, index) {
        number.addEventListener('click', function() {
            number.className += ' grow';
            input += (index+1);
            dots[input.length-1].className += ' active';
            if(input.length >= 4) {
                if(input !== correct) {
                    dots.forEach(function(dot, index) {
                        dot.className += " wrong";
                    });
                    document.body.className += " wrong";
                }
                else {
                    dots.forEach(function(dot, index) {
                        dot.className += " correct";
                    });
                    document.body.className += " correct";
                }
                setTimeout(function() {
                    dots.forEach(function(dot, index) {
                        dot.className = "dot";
                    });
                    input = "";
                }, 900);
                setTimeout(function() {
                    document.body.className = "";
                }, 2000);
            }
            setTimeout(function() {
                number.className = 'number';
            }, 1000);
        });
    });
})();

https://codepen.io/HBMBR/pen/bppXyE

Thanks for your help.

about 4 years ago · Juan Pablo Isaza
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!