I found a way to check if a string has only one space between whatever characters.
if (/^[^ ]* [^ ]*$/.test(name))
But I want the string to contain only alpha characters between one space. I'm new to regex so I'm not sure how to do this.
I tried this but it doesn't seem to work:
if (/^[a-z ]* [a-z ]*$/i.test(name))
"John Smith" should work but something like "John W Smith" or "111 111" should not work.