For website validation purposes, I need first name and last name validation.
For the first name, it should only contain letters, can be several words with spaces, an
For first and last names theres are really only 2 things you should be looking for:
Here is my regular expression:
var regex = /^[A-Za-z-,]{3,20}?=.*\d)/
1. Length
Here the {3,20} constrains the length of the string to be between 3 and 20 characters.
2. Content
The information between the square brackets [A-Za-z] allows uppercase and lowercase characters. All subsequent symbols (-,.) are also allowed.