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

121
Views
Password Strength level in react-native

I want to implement a password Checker, for example the password should contain one upper case, one small case, one special character at least.

But I want to make it separate, for example if the user doesn't enter an upper case I show him that the missing one is upper.

Here my implementation but it's not working:

const handlePasswordChange = (text) => {
let count = 0;
// One uppercase character
if (text.match(/^[A-Z]*$/)) {
  count++;
  setPasswordChecks((prev) => ({
    ...prev,
    upperCase: { ...prev.upperCase, isValid: true },
  }));
} else {
  setPasswordChecks((prev) => ({
    ...prev,
    upperCase: { ...prev.upperCase, isValid: false },
  }));
}
if (text.toUpperCase() !== text) {
  count++;
  setPasswordChecks((prev) => ({
    ...prev,
    lowerCase: { ...prev.lowerCase, isValid: true },
  }));
} else {
  setPasswordChecks((prev) => ({
    ...prev,
    lowerCase: { ...prev.lowerCase, isValid: false },
  }));
}

var format = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;

if (format.test(text)) {
  setPasswordChecks((prev) => ({
    ...prev,
    specialCharacter: { ...prev.specialCharacter, isValid: true },
  }));
} else {
  setPasswordChecks((prev) => ({
    ...prev,
    specialCharacter: { ...prev.specialCharacter, isValid: false },
  }));
}

// Check Level
console.log('count:: ', count);
if (count === 0 || count === 1) {
  setPasswordStrength('low');
} else if (count === 4) {
  setPasswordStrength('high');
} else {
  setPasswordStrength('medium');
}

};

Is there a better way to implement this ?

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!