I'm familiar with Java regex but not Javascript regex.
I want to check the validity of the string input if it looks like a first name. A first name can either be xxxx xxx or xxx where x is a letter. Note that in what I've said, the number of x's vary. So here's my code:
function checkName(name) {
var pattern = new RegExp('([A-Za-z]+|[A-Za-z]+\\s[A-Za-z]+)');
return pattern.test(name);
}
I've made a function that will process the name from the text input in my form. Now it is working for inputs such as Michael or Michael James. However, it also works on M3 for example which has a number and is supposed to be not working. So any help on this one experts out there in the world?