Hi,
Quick questio : I need to allow an input to only accept letters, from a-z to A-Z, but can't find any expression for that, using javascript test() method.
Cheers!
Hi,
Quick questio : I need to allow an input to only accept letters, from a-z to A-Z, but can't find any expression for that, using javascript test() method.
Cheers!
/^[a-zA-Z]+$/.test('sfjd')
Note: If you have any punctuation marks or anything, those are all invalid too. Dashes and underscores are invalid. \w
covers a-zA-Z and some other word characters. It all depends on what you need specifically.
There is a predefined class for this: /\w+/
(that is one or more word characters)
(just checked on java documentation: this allows also digits so maybe you don't want to use it)