【问题标题】:How to input only depending on the pattern如何输入仅取决于模式
【发布时间】:2018-02-23 06:59:47
【问题描述】:

我不确定这是否可行,但我想要一个输入框,用户只能在其中输入以下模式:(Number)(-)(Number)(Number)(Letter)

用户不能输入除此模式之外的任何其他内容。任何线索将不胜感激

【问题讨论】:

标签: html input


【解决方案1】:

您可以使用正则表达式(您在“模式”值中指定的内容)执行此操作:

<input type="text" pattern="regex comes here">

在你的情况下,我相信你会需要这个正则表达式:

[\d][-][\d][\d][a-zA-Z]

【讨论】:

    猜你喜欢
    • 2023-01-19
    • 2019-06-29
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-05
    相关资源
    最近更新 更多