HTML5 pattern allow specific special characters

微笑、不失礼 提交于 2019-12-01 19:16:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!