Published on January 26, 2024By DeveloperBreeze
// Function to check if a password meets certain strength criteria
function isValidPassword(password) {
// Customize validation rules as needed
const minLength = 8;
const hasUppercase = /[A-Z]/.test(password);
const hasLowercase = /[a-z]/.test(password);
const hasDigit = /\d/.test(password);
// Check if the password meets the criteria
return password.length >= minLength && hasUppercase && hasLowercase && hasDigit;
}
// Example password
const password = 'SecurePwd123';
// Log whether the password is valid to the console
console.log('Is Valid Password:', isValidPassword(password));
Comments
Please log in to leave a comment.