问题
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 ñ?
回答1:
pattern="[^0-9]*"
[…]
matches a single character^
anything except the following (when within[]
)0-9
digits zero through nine*
between zero and unlimited times
回答2:
For Not allowing Specific Symbols (dont allow , or .)
<form>
<input type="text" pattern="[^-,]+" title="'-' is not allowed">
<input type="submit">
</form>
来源:https://stackoverflow.com/questions/21282049/html5-pattern-allow-specific-special-characters