'How do I use ReGex with a webpage

I just found out about Regex, so sorry if it's a noob question, but I want to use it in a webpage, so I tried it, and it didn't work. Is there a library? SDK? or line of code I am missing?? Here is the code I have, that isn't working in my bootstrap5 project:

 <input name="phone" type ="tel" id="phone" pattern="\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}" placeholder="xxx-xxx-xxxx phone" />

Thanks,



Solution 1:[1]

Pattern is checked against on form submission.

So if you add form tag() and try submit, it will check your pattern

I confirmed your code is working in https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_pattern

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jinyoung So