So I have this regex to confirm if a name is valid or not, but if I were to add spaces before the name, it will display my error message.
Is there a way to convert my code to validate names like " Bob Joe" if there's extra spaces in the front? But I also wanna make sure nobody can just type "a b joe b bob" and still get a valid name.
Here's my current validation code
if (!values.name) {
errors.name = 'Name required';
} else if (!/^[A-Za-z]+/.test(values.name)) {
errors.name = 'Enter a valid name';
}