Skip to content Skip to sidebar Skip to footer

Html, Javascript. Regex On Numbers

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 the first nu

Solution 1:

Amazingly, you don't need JavaScript:

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

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

Post a Comment for "Html, Javascript. Regex On Numbers"