Regular expression to accept only characters (a-z) in a textbox
The pattern itself would be [a-z]
for single character and ^[a-z]+$
for entire line. If you want to allow uppercase as well, make it [a-zA-Z]
or ^[a-zA-Z]+$
Try this to allow both lower and uppercase letters in A-Z:
/^[a-zA-Z]+$/
Remember that not all countries use only the letters A-Z in their alphabet. Whether that is an issue or not for you depends on your needs. You may also want to consider if you wish to allow whitespace (\s
).