| 123456789101112131415161718192021222324252627282930313233343536 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <meta charset="UTF-8">
- <title>Login</title>
- <script>
- function s() {
- var username = document.getElementById("username").value;
- var password = document.getElementById("password").value;
- if (username === "" || password === "") {
- alert('请输入用户名或密码');
- return;
- }
- var form = document.getElementById("form");
- form.submit();
- }
- window.onload = function () {
- document.body.addEventListener('keydown', function (ev) {
- if (ev.keyCode === 13) {
- s();
- }
- });
- }
- </script>
- </head>
- <body>
- <form id="form" action="index.php" method="POST">
- <p>用户名:<input id="username" type="text" name="user"></p>
- <p>密码:<input id="password" type="password" name="password"></p>
- <input type="button" value="提交" onclick="s()">
- </form>
- </body>
- </html>
|