运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <form action="/action_page.php" method="get"> Pick a number between 2 and 5: <input type="number" id="myInput" name="quantity" min="2" max="5" required> <input type="submit" value="Submit"> </form> <p>If you submit the form with a number that is less than 2 or greater than 5, an alert message will occur.</p> <script> document.getElementById("myInput").addEventListener("invalid", myFunction); function myFunction() { alert("You must pick a number between 2 and 5. You chose: " + this.value); } </script> </body> </html>