I need to validate my password such that it must contain small alphabets, capital alphabets, digits and special characters. My code looks like this:
if (password.length < 8 || !/([a-zA-Z])/.test(password) || !/([0-9])/.test(password) || !/([!,%,&,@,#,$,^,*,?,_,~])/.test(password)){
console.log('Error: password is too weak');
}
As you can see I have put up many tests in the if condition. Can I make it a single regex to achieve my purpose?