I want to validate some fields in Input only contain charcters(userFirstName) and some alphanumeric charcters(userPassword) and some field as a specific format(userId)
That pattern there for example, ensures that there are at least three numbers and letters, underscore and dashes allowed in the first name. I’d think twice about being that narrow though, for some names contain special characters too.
These next methods add hasUppercase and hasLowercase methods to your fields:
but its showing “Invalid Format” many times.
My Requirement is
1)if I type any charcter other than A-Z and a-z then it should show error.
2)At any point if I type 2 charcters simultaneously then it is also showinng error messages
The ^ and $ are for the start and end of the string, which means that whatever matches in between must be the entire string, not just a part of it.
The square brackets are for a group of characters, in this case just uppercase letters.
The curly braces are where can specify a minimum and maximum number of characters that must match. In my earlier example it was a minimum of three, which seems suitable for a username.