运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> Facebook profile: <input type="url" id="myURL" name="fb"> <input type="submit"> </form> <p>Click the "Try it" button to specify a regular expression that the URL field's value will be checked against. Note that we also set the "title" to describe the pattern.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myURL").pattern = "http://www\.facebook\.com\/(.+)|https://www\.facebook\.com\/(.+)"; document.getElementById("myURL").title = "URL must start with http://www.facebook.com/"; document.getElementById("demo").innerHTML = "The URL field now only accept URL's that start with http://www.facebook.com/ or https://www.facebook.com/."; } </script> </body> </html>