HTML+JavaScript 用户登录界面
2014-04-11 10:44
387 查看
HTML+JavaScript 用户登录界面
主要功能:
1.简单的验证功能
2.登录画面始终显示在最中央
3.默认聚焦在输入框中。
代码如下:
运行效果:
主要功能:
1.简单的验证功能
2.登录画面始终显示在最中央
3.默认聚焦在输入框中。
代码如下:
<html> <head> <title>登录界面</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> //窗体改变大小时触发事件 window.onresize = setViewSize; var marginLeft=0; var marginTop=0; //设置画布大小,登录页面显示在屏幕最中间 function setViewSize() { //计算屏幕大小 var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; //设置登陆div的位置 marginLeft = (w-468)/2; marginTop = (h-262)/2; document.getElementById("loginFormMain").style.marginLeft=marginLeft; document.getElementById("loginFormMain").style.marginTop=marginTop; } //默认聚焦在用户名输入框上 function focusOnUsername() { //调整画布大小和登陆框位置 setViewSize(); //默认聚焦在输入框上 if (document.loginForm) { var usernameInput = document.loginForm.username; if (usernameInput) { usernameInput.focus(); } } return; } //检查用户输入 function checkLogin(){ if(checkUsername() && checkPassword()){ return true; } return false; } //检查登录用户名 function checkUsername(){ var username = document.loginForm.username; if(username.value.length!=0){ return true; }else{ alert("请输入用户名"); return false; } } //检查登录密码 function checkPassword(){ var password = document.loginForm.password; if(password.value.length!=0){ return true; }else{ alert("请输入密码"); return false; } } </script> </head> <body bgcolor="#1E81C2" onload="javascript:focusOnUsername();" > <form action="success.html" name="loginForm" > <div id="loginFormMain"> <table style="width:468px;height:262px;background-color: gray;text-align: center;"> <tr> <th colspan="2" align="center" >管理系统登录</th> </tr> <tr> <td>用户名:<input type="text" style="width: 200px;height: 30px;" name="username"></td> </tr> <tr> <td>密 码:<input type="password" style="width: 200px;height: 30px;" name="password"></td> </tr> <tr> <td align="center" ><input formmethod="post" type="submit" style="cursor: pointer;font-style: inherit;" name="submit" onclick="return checkLogin();" value="登录" > <input type="reset" style="cursor: pointer;" name=reset value="重置"></td> </tr> </table> </div> </form> </body> </html>
运行效果:
相关文章推荐
- html中设计用户登录界面
- servlet+mysql+html用户登录界面
- Html+Javascript+Ajax实现用户登录系统
- JSP作业2 - 利用html实现简单的用户登录注册界面
- JavaScript一个用户登录的简单界面
- 利用html、css、javascript、php同时交互数据库制作的注册登录界面
- JavaScript——用户登录界面
- 很漂亮的用户登录界面HTML模板
- 用 servlet 来创建一个用户登录界面
- 使用session验证的用户登录界面(简写)
- HTML-JavaScript-登录网页及验证
- MFC 简单的用户登录界面(在主程序窗口之前)
- 在Solaris里添加的普通用户无法登录图形界面
- Windows 7 安装 Oracle 10g 后 用sys用户登录em时,界面出来了,但报了一个错:java.lang.Exception: Exception in sending Request :: null
- iOS用户点击退出按钮,跳到登录界面的代码控制
- HTML登录界面的实现
- 多用户登录时,如何在登录界面上显示administrator账户
- SYS用户登录em管理界面失败
- 同学做的12306html登录界面
- Qt+html+JavaScript实现类似QQ聊天界面的气泡效果