var digits = p.charCodeAt(0);
var posNum = digits % p.length - (digits.toString().length - 1);
if (p.match(/\d/g).length < 2) { // if password doesn't contain at least two digits
p = p.replaceAt(posNum, digits);
}
This is basically what's already used to insert a single digit, but without the mod 10 to reduce the digits string (currently called "seed") to a single digit, and using its length (charcodes of base64 strings are the decimal codes of 0-9, A-Z, a-z, and the latter goes into 3 digits near z) in the posNum calculation.
This should already work, but the symbol insertion code would need to be adapted to ensure it doesn't overwrite the inserted digits.
Some sites require more than one digit, e.g. https://www.netemprego.gov.pt
The code should be something like:
This is basically what's already used to insert a single digit, but without the mod 10 to reduce the digits string (currently called "seed") to a single digit, and using its length (charcodes of base64 strings are the decimal codes of 0-9, A-Z, a-z, and the latter goes into 3 digits near z) in the posNum calculation.
This should already work, but the symbol insertion code would need to be adapted to ensure it doesn't overwrite the inserted digits.