// var formSource = 'https://100steps.withcic.cn/2017_gjty/user/onSubscribed/';
var formSource = '';
var phoneReg = /^1[0-9]{10}$/;
var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

if (document.referrer.indexOf(formSource) == 0) {
	$("#reserve").show();

	$("#phone").mouseout(function() {
		if (phoneReg.test($("#phone").val()))
			$("#phone-error").slideUp(700);
		else
			$("#phone-error").slideDown(700);
	});

	$("#email").mouseout(function() {
		if (emailReg.test($("#email").val()))
			$("#email-error").slideUp(700);
		else
			$("#email-error").slideDown(700);
	});

	$("#reserve").submit(function(e) {
		e.preventDefault();

		var data = {};
		$.each(
			$(this).serializeArray(),
			function(i, v) { data[v.name] = v.value; }
		);

		$.post(
			// './user/register/',
			'./test_register.php',
			JSON.stringify(data),
			function(response) {
				if (response.status == 0) {
					$("#status").addClass("success-status");

					$("#position").text(response.data.userPos);
					$("#waiting").text(response.data.userPos - response.data.curPos);
					$("#time").text($("#waiting").text() * response.data.avgServeTime);

					$("#reserve").hide();
					$("#position").hide();
					$("#status").fadeIn(1200, function() {
						$("#position").show(1300);
					});
				} else {
					alert(response.errorMessage);
				}
			}
		).fail(function() {
			alert('表单提交失败，请联系管理员');
		});
	});
} else {
	$.get(
		// './user/isUserInQueue/',
		'./test_isUserInQueue.php',
		function(response) {
			if (response.status == 0) {
				if (response.data.isInQueue) {
					$("#success").hide();
					$("#status-title").show();

					$("#position").text(response.data.userPos);
					$("#waiting").text(response.data.userPos - response.data.curPos);
					$("#time").text($("#waiting").text() * response.data.avgServeTime);

					$("#position").hide();
					$("#status").fadeIn(1200, function() {
						$("#position").show(1300);
					});
				} else {
					window.location.href = './guide.html';
				}
			} else {
				alert(response.errorMessage);
			}
		}
	).fail(function() {
		alert('获取状态信息失败，请联系管理员');
	});

	$("#fresh").click(function () {
		$.getJSON(
			// './queueinfo.json',
			'./test_queueinfo.php',
			function(d) {
				var waiting = $("#position").text() - d.curPos;
				waiting = waiting > 0 ? waiting : 0;
				if (waiting <= -5) {
					alert('您已过号五个，请重新取号><');
					window.location.href = './guide.html';
				}

				$("#waiting").fadeOut(300, function() {
					$("#waiting").text(waiting).fadeIn(500);
				});

				$("#time").fadeOut(300, function() {
					$("#time").text(waiting * d.avgServeTime).fadeIn(500);
				});
			}
		).fail(function() {
			alert('获取队列信息失败，请联系管理员');
		});
	});
}

@@ -383,24 +383,22 @@
 phone%22).
-mouseout
+change
 (functio
@@ -409,16 +409,17 @@
 %7B%0A%09%09if (
+!
 phoneReg
@@ -428,27 +428,22 @@
 est(
-$(%22#phone%22).val()))
+this.value)) %7B
 %0A%09%09%09
@@ -457,34 +457,36 @@
 ne-error%22).slide
-Up
+Down
 (700);%0A%09%09else%0A%09%09
@@ -474,29 +474,95 @@
 own(700);%0A%09%09
-else%0A
+%09$(this).on('input', function() %7B%0A%09%09%09%09if (phoneReg.test(this.value))%0A%09%09
 %09%09%09$(%22#phone
@@ -571,35 +571,44 @@
 rror%22).slide
-Down
+Up
 (700);%0A
+%09%09%09%7D);%0A%09%09%7D%0A
 %09%7D);%0A%0A%09$(%22#e
@@ -618,16 +618,14 @@
 l%22).
-mouseout
+change
 (fun
@@ -640,16 +640,17 @@
 %7B%0A%09%09if (
+!
 emailReg
@@ -659,27 +659,22 @@
 est(
-$(%22#email%22).val()))
+this.value)) %7B
 %0A%09%09%09
@@ -688,34 +688,36 @@
 il-error%22).slide
-Up
+Down
 (700);%0A%09%09else%0A%09%09
@@ -713,13 +713,79 @@
 ;%0A%09%09
-else%0A
+%09$(this).on('input', function() %7B%0A%09%09%09%09if (emailReg.test(this.value))%0A%09%09
 %09%09%09$
@@ -806,27 +806,36 @@
 %22).slide
-Down
+Up
 (700);%0A
+%09%09%09%7D);%0A%09%09%7D%0A
 %09%7D);%0A%0A%09$
@@ -891,16 +891,110 @@
 ult();%0A%0A
+%09%09if (!(phoneReg.test($(%22#phone%22).val())%0A%09%09%09&& emailReg.test($(%22#email%22).val())))%0A%09%09%09return;%0A%0A
 %09%09var da

Optimize Input Checker