How can I make user name and password (other fields like name, lastname) validator for registration in java? The best way will be probably using some regexp. The allowed characters should be probably only letters, numbers and “-” or “” and also letters like řščťž …
The validation of each field will be probably very similar.
Input is: String validatedFideld, allowed characters – some of theese: a-z, A-Z,-,,řščžýě… (== letters with diacritic)
Output is: true (= valid), false (= not vallid).
How can I make user name and password (other fields like name, lastname) validator
Share
Yes, you can use regular expressions.
\wmatches all letters (not only English letters), digits and-. So,(\w|-)+can match what you want.Personally I do not like when applications try to limit my possibilities for choosing password. Using special characters in password make it more secure, so limiting this is a bad practice. But you can indeed limit username or other fields.