I seem not to get it right to validate a user FirstName + LastName and checking for MiddleName like this:
John Doe - Valid
John M Doe - Valid
John Mr Doe - Invalid
John m Doe - Invalid
So, MiddleName can only be an uppercase letter.
What I came up with:
- FirstName + LastName should have at least 3 chars - OK
- Should be always FirstName and a LastName - OK
Cannot figure out how to check for MiddleName to have only 1 char if is present.
My current regex is like this:
var isValid = /^((\b[a-zA-Z]{3,40}\b)\s*){2,}$/.test($(this).val());
// ^((\b[a-zA-Z]{3,40}\b)\s*){2,}$ - actual regex