HTML

How To Set Phone Number Validation Using Regex In Simple HTML Form

In this article, We will learn how to set phone number validation using regex in simple HTML form.
Step-1: Creat form in HTML and use pattern in input.

<!DOCTYPE html>
<html>
    <header>
       <title>Phone number validation in html</title>
    </header>
    <div id="wrapper">
        <form>
            <label>Number</label>
            <input type="text" name="number" pattern="^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$" placeholder="+1 (416) 555-1212" required>
            <button type="submit">Submit</button>
        </form>
    </div>
</html>

Here is the result.

 

Tarun Thummar

I'm a JR. WordPress Developer at Vision Infotech.Skilled in HTML,CSS,PHP, WordPress, and jQuery.

Share
Published by
Tarun Thummar
Tags: HTML

Recent Posts

Testing hk

Testing

1 year ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

1 year ago

Operation

Testing

1 year ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

1 year ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

1 year ago

TETS NEW

test

2 years ago