How to allow only 10 digit number validation in Html?
I will give you a simple four examples of How to allow only 10 digit number validation in Html? It is numeric, It will be a max of 10 chars and the first digit is not zero allow. HTML default provides a pattern attribute provides. so you can simply create. ex: pattern=”[1-9]{1}[0-9]{9}”.
Example
<!DOCTYPE html>
<html>
<head>
<title>How to allow only 10 digit number validation in html?</title>
</head>
<body>
<form method="post">
<h5>How to allow only 10 digit number validation in html?</h5>
<label>Country code</label>
<input type="text" name="countrycode" placeholder="Enter Country code" title="Please Enter Proper Country code!" pattern="[1-9]{1}[0-9]{9}">
<button type="submit">Submit</button>
</form>
</body>
</html>
[1-9]: This matches a character in the range 1 to 9.
[0-9]: This matches a character in the range 0 to 9.
{1}: This is Quantifier and matches 1 of the preceding token.
{9}: This is Quantifier and matches 9 of the preceding token.