javascript regex : only english letters allowed

前端 未结 3 571
青春惊慌失措
青春惊慌失措 2020-12-05 09:54

Quick question: I need to allow an input to only accept letters, from a to z and from A to Z, but can\'t find any expression for that. I want to use the javascript test() me

3条回答
  •  盖世英雄少女心
    2020-12-05 10:15

    The answer that accepts empty string:

    /^[a-zA-Z]*$/.test('something')
    

    the * means 0 or more occurrences of the preceding item.

提交回复
热议问题