简体   繁体   English

电话模式<input type="“tel”">在 HTML

[英]Phone pattern for <input type=“tel”> in HTML

So I tried to run the following code to practice using HTML forms and the telephone no.所以我尝试运行以下代码来练习使用 HTML forms 和电话号码。 part is giving a problem.部分给出了问题。 When I type any telephone number which according to me should satisfy the requirements, it says "Please match the requested format".当我输入任何我认为应该满足要求的电话号码时,它会显示“请匹配请求的格式”。 I believe the requirements ask for a number with ten digits each of which are from 1 to 9. Did I write my requirements wrong?我相信要求要求一个十位数字,每个数字都是从 1 到 9。我的要求写错了吗? Help帮助

 <:DOCTYPE html><html> <head> <title> Forms in HTML5:) </title> </head> <body> <form align="center">Name:<input type="text" autocomplete><br><br> Email:<input type="email" name="email"><br><br> Date of Inception:<input type="time" name="usr_time"><br><br> Number of years completed(between 1 and 100):<input type="number" min="1" max="100"><br><br> Office phone number: <input type="tel" id="phone" name="phone" pattern="[0-9]{10}'' required><br><br> Add your homepage: <input type="url" name="homepage"><br><br> <input type="image" src="E./HTML1/SUBMIT-BUTTON.png" height="60" width="180" alt="click here to submit"> </form> </body> </html>

you wrote '' instead of " in pattern="[0-9]{10}"你写''而不是" in pattern="[0-9]{10}"

this code works:此代码有效:

<!DOCTYPE html><html>
<head>
<title>
Forms in HTML5 :)
</title>
</head>
<body>
<form align="center">Name:<input type="text" autocomplete><br><br>
Email:<input type="email" name="email"><br><br>
Date of Inception:<input type="time" name="usr_time"><br><br>
Number of years completed(between 1 and 100):<input type="number" min="1" 
max="100"><br><br>
Office phone number: <input type="tel" id="phone" name="phone" pattern="[0-9]. 
{10}" required><br><br>
Add your homepage:
<input type="url" name="homepage"><br><br>
<input type="image" src="E:/HTML1/SUBMIT-BUTTON.png" height="60" width="180" 
alt="click here to submit">
</form>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM