<!--#include file="/html/head.html"-->
<title>注册</title>
<!--#include file="/html/linkscript.html"-->
<script type="text/Javascript">
function checkPasswordLevel(value) {
if (!value) {
return 1;
}
if (value.length < 6) {
return 1;
}
if (value.length == 6 && (/[0-9]/.test(value) || /[a-z]/.test(value))) {
return 1;
}
if (value.length >= 6 && /[0-9]/.test(value) && /[a-z]/.test(value) && /(?=[\x21-\x7e]+)[^A-Za-z0-9]/.test(value)) {
return 3;
}
return 2;
}
$(function () {
$("#btnReg").click(function () {
var username = $("#username").val();
var password = $("#password").val();
var password2 = $("#password2").val();
var email = $("#email").val();
var phone = $("#PhoneNum").val();
var qq = $("#qq").val();
var school = $("#school").val();
var validCode = $("#validCode").val();
//todo:非空验证。JQuery EasyUI
if (phone == "") {
$("#phoneMsg").text("手机号不能为空!");
return;
}
else {
var reg = "^1(3[0-9]|4[57]|5[0-35-9]|7[01678]|8[0-9])\\d{8}$";
if (!reg.test(phone)) {
$("#phoneMsg").text("手机号不合法!");
return;
}
}
if (qq=="") {
$("#qqMsg").text("QQ号不能为空!");
return;
}
if (school=="") {
$("#schoolMsg").text("学校不能为空!");
}
if (validCode == "") {
$("#validateCodeMsg").text("验证码不能为空!");
return;
}
if (password == "") {
$("#userPasswordMsg").text("密码不能为空!");
return;
}
if (password != password2) {
$("#pwdError").text("两次输入的密码不一致!");
return;
}
$.ajax({
url: "UserController.ashx", type: "post",
dataType: "json",
data: { action: "registerSubmit", username: username, password: password, email: email, validCode: validCode, phone: phone, qq: qq, school: school },
success: function (data) {
if (data.status == "ok") {
alert("注册成功");
window.location.href = "index.shtml";
}
else {
alert("注册失败:" + data.msg);
//只有这句话刷新验证码是不安全的,需要后台也刷新验证码
$("#imgValidCode").attr("src", "UserController.ashx?action=createValideCode&id=" + new Date());
}
},
error: function () {
alert("注册请求失败");
}
});
});
$("#password").keyup(function () {