VamseeKrishna
VamseeKrishna

Reputation: 23

How to validate a mobile number starting with 7 or 8 or 9 and having a maximum length of 10 in html language? What is the attribute type?

<input type="tel" pattern="[7-9][0-9]{9}"> Please mention the attribute type. Thanks in advance.

Upvotes: 0

Views: 360

Answers (1)

You can use any of the following

    <input type="tel" pattern="(7|8|9)\d{9}" placeholder="(7|8|9)\d{9}"> 
    <input type="tel" pattern="[789][0-9]{9}" placeholder="[789][0-9]{9}">
    <input type="tel" pattern="[7-9][0-9]{9}" placeholder="[7-9][0-9]{9}"> 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tel Validation</title>
</head>
<body>
    <form action="#">
        <input type="tel" pattern="(7|8|9)\d{9}" placeholder="(7|8|9)\d{9}"> <br><br>
        <input type="tel" pattern="[789][0-9]{9}" placeholder="[789][0-9]{9}"> <br><br>
        <input type="tel" pattern="[7-9][0-9]{9}" placeholder="[7-9][0-9]{9}"> <br><br>
        <input type="submit" value="Submit">
    </form>
    
</body>
</html>

Upvotes: 1

Related Questions