I have the following problem, I need to validate a password field with at least 8 characters, being at least 2 numbers and the rest letters, they can be in any position.
12abcdef abcdef12
The expression I made works in the cases above:
function vSenha(senha) {
return /^(((?=.*[a-z])(?=.*\d{2,}).{8,16})|(?=.*\d{2,})(?=.*[a-z]).{8,16})$/.test(senha);
}
But if I put a letter and a number interspersed, the expression does not work. I was trying to mount an OR operator with regex but I did not succeed.
Ex how it does not work:
1a2b3c4d