簡體   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