I’m trying to solve a (simple) programming problem in Javascript and I can’t figure out how to get it working. I have a program which starts by reading in a text string using prompt.
The program outputs either “Valid name” or “Invalid name”, depending on whether the input names fit the required format, which is:
“last name, first name, middle initial”
where neither of the names can have more than 15 characters.
I know there’s an easy way to do this, but I can’t seem to find it anywhere. Thanks for your help!
I wouldn’t use
\w, as it includes characters such as_and the nine digits. Consider the regular expression in the following test: