1. 程式人生 > >登陸、註冊、忘記密碼、記住密碼、搜尋

登陸、註冊、忘記密碼、記住密碼、搜尋

一、註冊

html

<form id="register-form">                    
    <input type="email" name="email" class="email" id="registeremail" placeholder="E-mail*">
    <input type="password" name="password" class="psw" id="registerpsw" placeholder="Password*">  
    <input type="password" name="cpassword" class="cpsw" id="registercpsw" placeholder="Confirm password*">  
    <button class="creat" id="registercreat">create account</button>
    <p class="sendStatus"></p>                       
</form>

js

<script>
	$("#register-form").submit(function(e){         
        e.preventDefault();         
        var data = {}           
        var logEmail = $("#registeremail").val();            
        var logPwd = $("#registerpsw").val();          
        var logPwd2 = $("#registercpsw").val();         
        data.username = logEmail;           
        data.password = logPwd;         
        data.Pwd2 = logPwd2;            
        // var parameter = JSON.stringify(data);           
        var parameter = data;           
        $(".sendStatus").show();           
        $.ajax({                
            url: '/user/register',               
            method: "POST",             
            data: parameter,                
            success: function(res) {                    
                $(".sendStatus").html(res.msg);       
                $("#registeremail").val("");                 
                $("#registerpsw").val("");                    
                $("#registercpsw").val("");              
            }           
        });     
    });
</script>

二、搜尋

html

<form action="/product/search" method="post">
    <input type="text" class="h-search" name="search" placeholder="Search">
    <button type="submit" class="s-submit">Search</button>
</form>

無js程式碼

三、登陸

html

<form action="" id="login-form">                
    <input type="email" name="account" class="email" placeholder="E-mail*" id="log-email">
    <input type="password" name="password" class="psw" placeholder="Password*" id="log-pwd"> 
    <!-- <span class="rem_box"><em class="remem active"></em>Remember me</span> -->
    <input type="hidden" name="remember" class="remember">
    <button type="submit" class="log-btn">Log on</button>
    <p class="sendStatus"></p>                                    
</form>

js

<script>
	$("#login-form").submit(function(e){         
        e.preventDefault();         
        var data = {}           
        var logEmail = $("#log-email").val();            
        var logPwd = $("#log-pwd").val();    
        data.account = logEmail;
        data.password = logPwd;
        var parameter = data;
        $(".sendStatus").show();
        $.ajax({
            url: '/user/login',
            method: "POST",
            data: parameter,
            success: function(res) {
	            $(".sendStatus").html(res.msg);
	            $("#log-email").val("");
	            $("#log-pwd").val("");
            }
        });
    });
</script>

註冊

html

js