1

How can I check if string contain letter and/or spaces only. What I am trying is

/^[a-zA-Z\\s]+&/.test(name_value)

But it doesn't work at all and I am not very familiar with regexes. Correct input can be:

Toma Tomov
Ivan Petrov
Toma
Ivan

Incorrect input:

Toma%Tomov
$Ivan Petrov
etc.
Toma Tomov
  • 1,476
  • 19
  • 55
  • https://regexper.com/#%2F%5E%5Ba-zA-Z%5C%5Cs%5D%2B%26%2F – epascarello Feb 15 '21 at 18:35
  • You can replace your regex with something like "[a-zA-Z ]+" without quotes, if you want to check character and space string only. There is a space after 'A-Z'. – Akshay Mishra Feb 15 '21 at 18:38
  • try this: https://stackoverflow.com/questions/11896599/javascript-code-to-check-special-characters – Rick Feb 15 '21 at 18:38
  • i believe this question is already asked many times. https://stackoverflow.com/questions/8059370/javascript-regex-for-alphabetic-characters-and-spaces – D. Seah Feb 15 '21 at 18:40

0 Answers0