|
@@ -283,6 +283,46 @@
|
|
|
}
|
|
|
}
|
|
|
</style>
|
|
|
+ <script type="text/javascript">
|
|
|
+ /* 获取引擎对象(兼容IE6之前的游览器) */
|
|
|
+ function getXhr() {
|
|
|
+ var xhr;
|
|
|
+ try {
|
|
|
+ xhr = new XMLHttpRequest();
|
|
|
+ } catch (e) {
|
|
|
+ xhr = new ActiveObject("Microsoft.XMLHTTP");
|
|
|
+ }
|
|
|
+ return xhr;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 检查账号是否被注册 */
|
|
|
+ function checkName() {
|
|
|
+ var email = document.getElementById("email");
|
|
|
+ var value = email.value;
|
|
|
+ var emailtip = document.getElementById("emailtip");
|
|
|
+ //创建异步引擎对象
|
|
|
+ var xhr = getXhr();
|
|
|
+
|
|
|
+ //步骤一:打开引擎,method用于设置请求的方式:get或者post
|
|
|
+ /* url设置请求的路径,async设置是同步操作还是异步操作,默认是ture(异步) */
|
|
|
+ xhr.open("post", "RegisterServlet");
|
|
|
+ /* post方式提交需要设置请求头 */
|
|
|
+ xhr.setRequestHeader("Content-Type",
|
|
|
+ "application/x-www-form-urlencoded");
|
|
|
+ /* 步骤二:发送 */
|
|
|
+ xhr.send("email=" + value);
|
|
|
+ /* 步骤三:检测引擎的状态改变 */
|
|
|
+ xhr.onreadystatechange = function() {
|
|
|
+ /* 判断响应是否已经接收完成和判断是否正常响应 */
|
|
|
+ if (xhr.readyState == 4 && xhr.status == 200) {
|
|
|
+ /* 接收响应的字符串信息 */
|
|
|
+ emailtip.innerText = xhr.responseText;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
@@ -294,9 +334,9 @@
|
|
|
|
|
|
</div>
|
|
|
<span class="form_span">It’s quick and easy. </span>
|
|
|
- <input type="text" class="form_input" placeholder="Email" name="email" id="email">
|
|
|
- <input type="text" class="form_input" placeholder="Password" name="pwd" id="pwd">
|
|
|
- <input type="text" class="form_input" placeholder="RePassword" name="userRePwd" id="userRePwd">
|
|
|
+ <input type="text" class="form_input" placeholder="Email" name="email" id="email" onblur="checkName()"><span id="emailtip"></span>
|
|
|
+ <input type="password" class="form_input" placeholder="Password" name="pwd" id="pwd">
|
|
|
+ <input type="password" class="form_input" placeholder="RePassword" name="userRePwd" id="userRePwd">
|
|
|
<br/>
|
|
|
<button class="form_button button submit">SIGN UP</button>
|
|
|
</form>
|
|
@@ -316,7 +356,6 @@
|
|
|
</div>
|
|
|
</body>
|
|
|
|
|
|
-</html>
|
|
|
-</body>
|
|
|
|
|
|
</html>
|
|
|
+
|