Test if string contains only letters (a-z + é ü ö ê å ø etc..)

后端 未结 12 1317
不思量自难忘°
不思量自难忘° 2020-12-04 18:12

I want to match a string to make sure it contains only letters.

I\'ve got this and it works just fine:

var onlyLetters = /^[a-zA-Z]*$/.test(myString)         


        
12条回答
  •  眼角桃花
    2020-12-04 18:39

    You could use a blacklist - a list of characters to exclude.

    Also, it is important to verify the input on server-side, not only on client-side! Client-side can be bypassed easily.

提交回复
热议问题