Reputation: 223
I have an input text field in my form but i don't know how to filter the input that can all letters and special characters but will not accept numbers.
<input pattern="[A-Za-z]{1,25}" maxlength="25" type="text" required="required" style="height:20px" value="">
It doesn't accept when i enter my middle name "pacaña"
how could i alter the pattern that can accept all characters/special-characters and other special characters like ñ?
Upvotes: 5
Views: 52953
Reputation: 1
I crashed into the same problem, wanted to allow french accents into a text field...
After a bit of trial and error, turns out you can use pattern="^[\p{L}]${1,25}
to allow ASCII letters and Unicode variants, accented letters and special characters.
Upvotes: 0
Reputation: 51
Allow any special symbols : [A-Za-z\W+]
<form action="/action_page.php">
<label for="country_code">Special Symbols Not Allowed:</label>
<input type="text" pattern="[A-Za-z]{1,25}" title="Special characters are not allowed!"><br><br>
<input type="submit">
</form>
<br><br>
<form action="/action_page.php">
<label for="country_code">Special Symbols Allowed:</label>
<input type="text" pattern="[A-Za-z\W+]{1,25}" title="Special characters are not allowed!"><br><br>
<input type="submit">
</form>
Upvotes: 0
Reputation: 3207
pattern="[^0-9]*"
[…]
matches a single character^
anything except the following (when within []
)0-9
digits zero through nine*
between zero and unlimited timesUpvotes: 10
Reputation:
For Not allowing Specific Symbols (dont allow , or .)
<form>
<input type="text" pattern="[^-,]+" title="'-' is not allowed">
<input type="submit">
</form>
Upvotes: 3