因此,我尝试运行以下代码来练习使用HTML表单和电话号码。部分是给出了一个问题。当我输入任何我认为应该满足要求的电话号码时,它会显示“请匹配所要求的格式”。我相信需求要求的是一个十位数字,每个数字都是从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>
发布于 2021-01-27 05:18:10
您在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>https://stackoverflow.com/questions/65908424
复制相似问题