HTML, Javascript. RegEx on numbers

后端 未结 1 575
你的背包
你的背包 2021-01-29 07:24

I have an input field for phone numbers. If the first number is 8, it should be automatically removed when a person types it.

If a person starts writing a number with t

相关标签:
1条回答
  • 2021-01-29 07:46

    Amazingly, you don't need JavaScript:

    <input type="tel" name="phone" pattern="[^8].*"
                                          title="Numbers cannot start with 8" />
    

    And it will work even if the user has JavaScript disabled :)

    0 讨论(0)
提交回复
热议问题