js如何實現點擊按鈕后彈出驗證框
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
![]() ![]() <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>驗證框示例</title> <script> function validateInput() { const correctAnswer = "1234"; // 假設正確答案是 1234 const userInput = prompt("請輸入密碼:"); if (userInput === correctAnswer) { alert("驗證通過,繼續進行!"); // 在這里可以繼續進行其他操作 } else { alert("輸入錯誤,請重試!"); } } </script> </head> <body> <button onclick="validateInput()">點擊驗證</button> </body> </html> ? 該文章在 2025/2/25 15:02:05 編輯過 |
關鍵字查詢
相關文章
正在查詢... |