1. 程式人生 > >HTML5寫的簡單登入頁面

HTML5寫的簡單登入頁面

整體效果圖:
這裡寫圖片描述
主要程式碼:


<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
    <meta charset="utf-8">
    <title>
        歡迎來到登入介面
    </title> 
     <meta name="viewport"content="width=device-width,initial-scale=1.0">
     <meta name="description"content=""
>
<meta name="author"content=""> <!---CSS--> <link rel="stylesheet" type="text/css" href="css/supersized.css"> <link rel="stylesheet" type="text/css" href="css/login.css"> <link rel="stylesheet" href="css/bootstrap.min.css"> <script src="js/jquery-1.8.2.min.js"
>
</script> <script type="text/javascript"src="js/jquery.form.js"></script> <script type="text/javascript"src="js/tooltips.js"></script> <script type="text/javascript"src="js/login.js"></script> <body> <div class="page-container"> <div
class="main_box">
<div class="login_box"> <div class="login_logo"> <label for="j_loginname"class="t"> <h2> <font color="red"> 歡迎使用登入系統 </font> </h2> </label> </div> <div class="login_form"> <form action="index.html"id="login_form"method="post"> <div class="form-group"> <label for="j_username" class="t">郵 箱:</label> <input id="email" value="" name="email" type="text" class="form-control x319 in" autocomplete="off"> </div> <div class="form-group"> <label for="j_password" class="t">密 碼:</label> <input id="password" value="" name="password" type="password" class="password form-control x319 in"> </div> <div class="form-group"> <label for="j_captcha" class="t">驗證碼:</label> <input id="j_captcha" name="j_captcha" type="text" class="form-control x164 in"> <img id="captcha_img" alt="點選更換" title="點選更換" src="images/captcha.jpeg" class="m"> </div> <div class="form-group"> <label class="t"></label> <label for="j_remember" class="m"> <input id="j_remember" type="checkbox" value="true">&nbsp;記住登陸賬號!</label> </div> </div> <div class="form-group space"> <label class="t"></label>    <button type="button"id="submit_btn" class="btn btn-primary btn-lg">&nbsp;登&nbsp;錄&nbsp </button> <input type="reset" value="&nbsp;&nbsp;&nbsp;&nbsp;重&nbsp;置&nbsp;" class="btn btn-default btn-lg"> </div> </form> </div> </div> </div> </div> <script src="js/supersized.3.2.7.min.js"></script> <script src="js/supersized-init.js"></script> <script src="js/scripts.js"></script> <div style="text-align:center;"> <p>來源:<a href="http://www.mycodes.net/" target="_blank"></a></p> </div> </body> </head> </html>

javasript中的程式碼

// JavaScript Document
//支援Enter鍵登入
        document.onkeydown = function(e){
            if($(".bac").length==0)
            {
                if(!e) e = window.event;
                if((e.keyCode || e.which) == 13){
                    var obtnLogin=document.getElementById("submit_btn")
                    obtnLogin.focus();
                }
            }
        }

        $(function(){
            //提交表單
            $('#submit_btn').click(function(){
                show_loading();
                var myReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; //郵件正則
                if($('#email').val() == ''){
                    show_err_msg('郵箱還沒填呢!');    
                    $('#email').focus();
                }else if(!myReg.test($('#email').val())){
                    show_err_msg('您的郵箱格式錯咯!');
                    $('#email').focus();
                }else if($('#password').val() == ''){
                    show_err_msg('密碼還沒填呢!');
                    $('#password').focus();
                }else{
                    //ajax提交表單,#login_form為表單的ID。 如:$('#login_form').ajaxSubmit(function(data) { ... });
                    //show_msg('登入成功咯!  正在為您跳轉...','/');    
                }
            });
        });