        function Login(){
            window.location.href='/login';
        };

        $(function (){
            var firstname = $("input[name='firstname']");
            var lastname = $("input[name='lastname']");
            var email = $("input[name='email']");
            var phone = $("input[name='phone']");
            var username = $("input[name='username']");
            var password = $("input[name='password']");
            var confirmpwd = $("input[name='confirmpwd']");
            var status = false;
            var form = $("form");

            firstname.blur(function(){      // rita blur 取消焦點時
                var span = $("#firstname-span");
                if(firstname.val() == ''){
                    span.text("Field is requied");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                };
            });

            lastname.blur(function(){
                var span = $("#lastname-span");
                if(lastname.val() == ''){
                    span.text("Field is requied");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                };
            });

            email.blur(function(){
                var span = $("#email-span");
                if(email.val().indexOf('@') == -1){
                    span.text("Incorrect email address");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                    $.get('/check_email','email='+email.val(),function(resText){
                        if(resText.errMsg){
                            $("#firstname_span").text("This email is already registered");
                            status = false;
                        }else{
                            $("#firstname_span").text("");
                            status = true;
                        };
                    },'json');
                };
            });

            phone.blur(function(){
                var span = $("#phone-span");
                if(phone.val().length < 8 || isNaN(phone.val()) == true){
                    span.text("Wrong phone number");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                };
            });

            username.blur(function(){
                $.get("/check_username","username="+username.val(),function(resText){
                    if(resText.errMsg){
                        $("#firstname-span").text("This username is already registered");
                        status = false;
                    }else{
                        $("#firstname-span").text("");
                        status = true;
                    };
                },'json');
            });

            confirmpwd.blur(function(){
                var span = $("#password-span");
                if(password.val() != confirmpwd.val()){
                    span.text("Passwords does not match");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                };
            });

            form.submit(function(){
                if((status == true) && (password.val() != '') && (confirmpwd.val() != '')){
                    return true;
                }else{
                    alert("Please type your infomation");
                    return false;
                };
            });
        });