繁体   English   中英

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

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

所以我尝试运行以下代码来练习使用 HTML forms 和电话号码。 部分给出了问题。 当我输入任何我认为应该满足要求的电话号码时,它会显示“请匹配请求的格式”。 我相信要求要求一个十位数字,每个数字都是从 1 到 9。我的要求写错了吗? 帮助

 <: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>

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

此代码有效:

<!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