【问题标题】:HTML5 input validate at least 1 letter and 1 number in the fieldHTML5 输入验证字段中至少有 1 个字母和 1 个数字
【发布时间】:2018-01-08 20:56:19
【问题描述】:

我被 HTML5 表单验证困住了。我需要满足这些参数:

  • 至少 1 个数字

  • 至少 1 个字母(任何大小写)

如何使用模式属性来做到这一点?例如:

<input type="password" pattern="myPattern" />

【问题讨论】:

    标签: html forms validation


    【解决方案1】:
    pattern="(?=.*\d)(?=.*[a-zA-Z]).*"
    

    请尝试谷歌搜索;关于如何使用pattern的许多例子可以在这里看到:
    https://www.w3schools.com/tags/att_input_pattern.asp

    【讨论】:

      猜你喜欢
      • 2017-02-24
      • 1970-01-01
      • 2010-11-02
      • 1970-01-01
      • 2020-08-20
      • 2018-08-30
      • 1970-01-01
      • 2010-12-28
      • 1970-01-01
      相关资源
      最近更新 更多