Jun-02-2024, 06:16 AM
If your validator is invalid: Do it yourself!
But I don't know how to use Python for webpages!
import re # password must contain at least 3 CAPITAL LETTERS # password must contain at least 3 digits # password must contain at least 1 small letter def validator(): e = re.compile(r'\A(?=[^a-z]*[a-z])(?=(?:[^A-Z]*[A-Z]){3})(?=\D*\d{3}).*') print('Your password MUST contain at least 1 small letter.') print('Your password MUST contain at least 3 capital letters and at least 3 digits.') print('You password may contain spaces and any or all of these: @#$%^&* to make it safer.') pw1 = input('Please enter a password you can remember. ') while not e.match(pw1): print('Your password MUST contain at least 3 capital letters and at least 3 digits.') print('You password may contain spaces and any or all of these: @#$%^&* to make it safer.') pw1 = input('Please enter a password you can remember. ') pw2 = input('Please enter the password you just wrote again. ') while not pw1 == pw2: print('Looks like you have problems with simple instructions. Let\'s try that again!') pw1 = input('Please enter a password you can remember. ') while not e.match(pw1): print('Your password MUST contain at least 3 capital letters and at least 1 digit.') print('You password may contain any or all of these: @#$%^&* to make it safer.') pw1 = input('Please enter a password you can remember. ') print('Now, please try to write the EXACT SAME password again, thank you.') print('If you can not write the same password again, this loop will never end ... ') pw2 = input('Please enter the password you you just wrote again. ') return pw1 password = validator()Gives:
Output:password = validator()
Your password MUST contain at least 1 small letter.
Your password MUST contain at least 3 capital letters and at least 3 digits.
You password may contain spaces and any or all of these: @#$%^&* to make it safer.
Please enter a password you can remember. Pedro Juan 1988
Your password MUST contain at least 3 capital letters and at least 3 digits.
You password may contain spaces and any or all of these: @#$%^&* to make it safer.
Please enter a password you can remember. Juan Pedro Sanchez 1999
Please enter the password you just wrote again. Juan Pedro Sanchez 1999
Although, I would rather use PHP to do this on a register.html page!But I don't know how to use Python for webpages!