Reputation: 1207
I'm really new to regex but I need to find a way to add a filter to a HTML5 form:
<input type="text" required="true" name="firstname" pattern="WHAT DO I PUT HERE">
Could anyone help me with what to put in the pattern attribute, for example
Accepted:
John
Frank
Not accepted:
Ke$ha
B0B
(Only alphabetic characters are accepted.)
Upvotes: 2
Views: 9992
Reputation: 1658
Some nice examples: http://html5pattern.com/
In your case I would use:
[a-zA-Z]+
Upvotes: 5
Reputation: 8609
You aren't too specific, but I'll assume you want to rule out nonalphabetic characters.
The pattern for non-empty alphabetic-only word is
[a-zA-Z]+
where a-z
stands for the range of lowercase letters, A-Z
for the range of uppercase letter. [a-zA-Z]
then means any letter and +
means at least one.
Upvotes: 1