﻿<!DOCTYPE html>
<html lang="en">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>FtvStory - 會員管理系統</title> 
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Time of Madness, Red Stains the World">
    
  <link href="static/css/notice_view.build.css" rel="stylesheet">
    <style type="text/css">
    <!--
    .STYLE1 {
      color: #565555;
    }

    .table-c table td {
      font-size: 16px;
      color:#fff;
      padding: 15px 5px 1px 1px;
      border-bottom-width: 0px;
      border-top-style: none;
      border-right-style: none;
      border-bottom-style: solid;
      border-left-style: none;
      border-bottom-color: #e3d6d6;
    }

    .table-c table a {
      text-decoration: none;
      color: #ff0000;
    }

    .banklist ul {
      position: relative;
    }

    .STYLE3 {
      font-size: 16px;
      color: green;
    }
    
    .STYLE2 {
      font-size: 16px;
      color: #c98f06;
    }
 .drag{
            width: 60%;
            height: 40px;
            left:0px;
            line-height: 40px;
            background-color: #5f5f5f;
            position: relative;
            margin:0 auto;
        }
        .bg{
            width:40px;
            height: 100%;
            position: absolute;
            background-color: #75CDF9;
        }
        .text{
            position: absolute;
            width: 100%;
            height: 100%;
            text-align: center;
            user-select: none;
        }
        .btn{
            width:40px;
            height: 38px;
            position: absolute;
            border:1px solid #ccc;
            cursor: move;
            text-align: center;
            background-color: #fff;
            user-select: none;
            color:#666;
        }
    -->
  </style>
</head>
<body>

  <div class="body-wrap">
	  <div id="head"></div>
    <div class="page-wrap page-scroller">
      <div class="bg-page-wrap bg-fixed" id="bg-page-view"></div>
      <div class="container container-col8" id="notice-view-content">
        <div class="news-view-wrap">
          <div class="news-view-head">

            <h5 class="news-view-date"></h5>
            <h3 class="news-view-headline"></h3>
          </div>
          <div class="news-view-body">
            <div class="inner">
								<h2>會員注冊</h2>
								<div id="table-c" class="table-c">
									<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1">
										<form name="f1" action="" method="post" onSubmit="return checkfrom(this)">
											<tr>
												<td align="left" width="43%"><input name="username" type="text"
														id="username" class="app_input" maxlength="20"
														style="width:98%; height:40px; font-size:16px;"
														placeholder="用戶名"
														onBlur="validate_username(this.value)" />
												</td>
											</tr>
											<tr>
												<td id="test_user" align="left" width="98%"></td>
											</tr>
											<tr>
												<td align="left"><input name="passwd" type="password" id="passwd"
														class="app_input" maxlength="20"
														style="width:98%; height:40px; font-size:16px;"
														placeholder="密碼"
														onBlur="validate_password(this.value)" />
												</td>
											</tr>
											<tr>
												<td id="test_pw" align="left"></td>
											</tr>
											<tr>
												<td align="left"><input name="repasswd" type="password" id="repasswd"
														class="app_input" maxlength="20"
														style="width:98%; height:40px; font-size:16px;"
														placeholder="確認密碼"
														onBlur="validate_password2(this.value)" />
												</td>
												
											</tr>
											<tr>
												<td id="is_test_pw" align="left"></td>
											</tr>
											<tr>
												<td align="left"><input name="email" type="email" id="email"
														class="app_input" maxlength="40"
														style="width:98%; height:40px; font-size:16px;"
														placeholder="郵箱"
														onBlur="validate_email(this.value)" />
												</td>
										</tr>
											<tr>
												<td id="test_email" align="left"></td>
											</tr>

                        <tr>
                         <td align="left">
       										 <div class="am-form-group">
								             <div class="drag">
               								<div class="bg"></div>
               								<div class="text" id="testify" onselectstart="return false;">拖動滑塊驗證</div>
               									<div class="btn">&gt;&gt;</div><br>                            
             								</div>
 													 </div>
                   
                         </td>
                        </tr>

											<tr>
												<td height="30" align="center"><span class="STYLE1">已有賬號? </span><a href="members.aspx"
														target="_blank">登入賬號</a></td>
											</tr>
											<tr>
												<input type="hidden" name="ptype" value="login" id="faceValue" />
                        <input type="hidden" name="logincode" value="" id="logincode"/>
												<td height="30" align="left"><input name="Submit"
														type="submit" class="btn2 " value="創建賬號"
														onClick="return validate_form()"
														style="width:98%; height:50px;cursor:pointer; font-size:16px;background-color: red;color:#fff;font-weight:bold;"/>
													&nbsp&nbsp
												</td>
											</tr>
										</form>
									</table>
								</div>
              
            </div>
          </div>
          <div class="news-preview-wrap">

          </div>

        </div>
      </div>
      
    </div><!-- page wrap -->
    <div id="footer"></div>
  </div><!-- body-wrap -->

</body>
</html>
<script type="text/javascript">
  function back() {
    document.forms.f1.action = "members.aspx";
    document.forms.f1.submit();
  }
</script>
<script defer src="static/js/vendors.bundle.js"></script>
<script src="static/js/jquery-3.4.1.min.js"></script>
<script defer src="static/js/notice_view.bundle.js"></script>
<script
  type="text/javascript">$('#head').load('../center/head.html'); 
  $('#footer').load('../center/footer.html'); </script>
  
<script type="text/javascript">
	//onblur失去焦点事件，用户离开输入框时执行 JavaScript 代码：
	//函数1：验证邮箱格式
	function validate_username(username) {
		//定义正则表达式的变量:邮箱正则
		var usernamReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		//console.log(username);
		if (username.length < 6 || username.length > 12) {
			document.getElementById("test_user").innerHTML = "<font color='red' size='3px'>字母和數字6-12位</font>";

		}
		else {
			document.getElementById("test_user").innerHTML = "<font color='green' size='3px'>√賬號格式正確!</font>";
		}
	}
	//函数1：验证邮箱格式
	function validate_email(email) {
		//定义正则表达式的变量:邮箱正则
		var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		//console.log(username);
		if (email != "" && email.search(emailReg) != -1) {
			document.getElementById("test_email").innerHTML = "<font color='green' size='3px'>√郵箱格式正確!</font>";
		} else {
			document.getElementById("test_email").innerHTML = "<font color='red' size='3px'>請輸入有效的郵箱地址</font>";
		}
	}
	//函数2：验证密码是否符合要求：匹配6位密码，由数字和字母组成：
	function validate_password(password) {
		//^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6-10}$
		//测试密码：12345y
		var passwordReg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,11}$/;
		if (password != "" && passwordReg.test(password)) {
			document.getElementById("test_pw").innerHTML = "<font color='green' size='3px'>√</font>";
		} else {
			document.getElementById("test_pw").innerHTML = "<font color='red' size='3px'>字母和數字6-20位</font>";

		}
	}

	//函数3：验证两次输入的密码是否一样
	function validate_password2(password2) {
		var password = document.getElementById("passwd").value;
		//测试：console.log(password);
		//测试：console.log(password2);
		if (password == "") {
			document.getElementById("is_test_pw").innerHTML = "<font color='red' size='3px'>請輸入密碼!</font>";
		} else if (password == password2) {
			document.getElementById("is_test_pw").innerHTML = "<font color='green' size='3px'>√</font>";
		} else {
			document.getElementById("is_test_pw").innerHTML = "<font color='red' size='3px'>密碼驗證有誤!</font>";

		}
	}
	//函数2：phone：
	function validate_phone(phone) {
		//^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6-10}$
		//测试密码：12345y
		var phoneReg = /^[0-9]+.?[0-9]{10,11}$/;
		if (phone != "" && phoneReg.test(phone)) {
			document.getElementById("test_phone").innerHTML = "<font color='green' size='3px'>√</font>";
		} else {
			document.getElementById("test_phone").innerHTML = "<font color='red' size='3px'>'11' 位，字符不夠，可在最前面加'0'!</font>";

		}
	}
	//函数4：验证表单是否已经填好
	function validate_form() {
		var username = document.getElementById("username").value;
		var email = document.getElementById("email").value;
		var phone = document.getElementById("phone").value;
		var password = document.getElementById("passwd").value;
		var password2 = document.getElementById("repasswd").value;
		//console.log("表单填写正确，可以正常提交！");

		//这三个，如果任何一个有问题，都返回false
		//18128@qq.com		12345y
		var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		var passwordReg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,11}$/;
		var phoneReg = /^[0-9]+.?[0-9]{10,11}$/;
		if (username != "" && emailReg.test(email) && phoneReg.test(phone) && username.length > 5 && username.length < 12) {
			if (password != "" && passwordReg.test(password)) {
				if (password2 == password) {
					alert("信息填寫正確!");
					console.log("信息填寫正確!");
					return true;
				} else {
					alert("密碼驗證失敗，請重新填寫!");
					console.log("密碼驗證失敗，請重新填寫!");
					return false;
				}
			} else {
				alert("密碼格式錯誤!");
				console.log("密碼格式錯誤!");
				return false;
			}
		} else {
			alert("賬號格式錯誤!");
			console.log("賬號格式錯誤!");
			return false;
		}
	}
</script>
   <script>
     //一、定义一个获取DOM元素的方法
        var $ = function(selector){
                return  document.querySelector(selector);
            },
            box = $(".drag"),//容器
            bg = $(".bg"),//背景
            text = $(".text"),//文字
            btn = $(".btn"),//滑块
            success = false,//是否通过验证的标志
            distance = box.offsetWidth - btn.offsetWidth;//滑动成功的宽度（距离）

        //二、给滑块注册鼠标按下事件
        btn.onmousedown = function(e){

            //1.鼠标按下之前必须清除掉后面设置的过渡属性
            btn.style.transition = "";
            bg.style.transition ="";

            //说明：clientX 事件属性会返回当事件被触发时，鼠标指针向对于浏览器页面(或客户区)的水平坐标。

            //2.当滑块位于初始位置时，得到鼠标按下时的水平位置
            var e = e || window.event;
            var downX = e.clientX;

            //三、给文档注册鼠标移动事件
            document.onmousemove = function(e){

                var e = e || window.event;
                //1.获取鼠标移动后的水平位置
                var moveX = e.clientX;

                //2.得到鼠标水平位置的偏移量（鼠标移动时的位置 - 鼠标按下时的位置）
                var offsetX = moveX - downX;

                //3.在这里判断一下：鼠标水平移动的距离 与 滑动成功的距离 之间的关系
                if( offsetX > distance){
                    offsetX = distance;//如果滑过了终点，就将它停留在终点位置
                }else if( offsetX < 0){
                    offsetX = 0;//如果滑到了起点的左侧，就将它重置为起点位置
                }

                //4.根据鼠标移动的距离来动态设置滑块的偏移量和背景颜色的宽度
                btn.style.left = offsetX + "px";
                bg.style.width = offsetX + "px";

                //如果鼠标的水平移动距离 = 滑动成功的宽度
                if( offsetX == distance){

                    //1.设置滑动成功后的样式
                    text.innerHTML = "驗證成功";
                    text.style.color = "#fff";
                    btn.innerHTML = "&radic;";
                    btn.style.color = "green";
                    bg.style.backgroundColor = "lightgreen";

                    //2.设置滑动成功后的状态
                    success = true;
                    //成功后，清除掉鼠标按下事件和移动事件（因为移动时并不会涉及到鼠标松开事件）
                    btn.onmousedown = null;
                    document.onmousemove = null;

                    //3.成功解锁后的回调函数
                  var oldElement = document.getElementById("logincode");
                        oldElement.value="+logincode+";
                }
            }

            //四、给文档注册鼠标松开事件
            document.onmouseup = function(e){

                //如果鼠标松开时，滑到了终点，则验证通过
                if(success){
                    return;
                }else{
                    //反之，则将滑块复位（设置了1s的属性过渡效果）
                    btn.style.left = 0;
                    bg.style.width = 0;
                    btn.style.transition = "left 1s ease";
                    bg.style.transition = "width 1s ease";
                }
                //只要鼠标松开了，说明此时不需要拖动滑块了，那么就清除鼠标移动和松开事件。
                document.onmousemove = null;
                document.onmouseup = null;
            }


        }
        </script>