// JavaScript Document
function chech_login_user(){
	var input_username = document.getElementById('membernam');
	if (input_username.value == undefined || input_username.value == '' || input_username.value == null){
		str = '用户名不能为空';
		alert(str);
		return false;
	};
	
	var input_password = document.getElementById('memberpas');
	if (input_password.value == undefined || input_password.value == '' || input_password.value == null){
		str = '用户密码不能为空';
		alert(str);
		return false;
	};
	var patrn=/^[0-9a-zA-Z]{6,15}$/; 
	if (!patrn.exec(input_password.value)){
		str = '密码长度必须为 6-15 由数字和字母组成的字符';
		alert(str);
		return false;
	};
	
	var input_code = document.getElementById('confirmation');
	if (input_code.value == undefined || input_code.value == '' || input_code.value == null){
		str = '验证码不能为空';
		alert(str);
		return false;
	};
	
	var patrn=/^[0-9]{4,4}$/; 
	if (!patrn.exec(input_code.value)){
		str = '验证码必须为 4个 由数字组成的字符';
		alert(str);
		return false;
	};
	
	$.ajax({
		url: 'confirmation.php', 
		type: 'POST', 
		data:{confirmation:input_code.value}, 
		dataType: 'html', 
		timeout: 10000, 
		error: function(){
			//alert('Error loading PHP document');
			//alert("连接网络失败");
			return false;
		}, 
		success: function(result){
			result = result.replace(" ","");
			if (result != 'true'){
				alert(result);
				document.getElementById('confirmation_img').src='inc/authimg.php?'+Math.random();
				return false;
			} else {
				$.ajax({
					url: 'loginuser.php', 
					type: 'POST', 
					data:{username:input_username.value, password:input_password.value, code:input_code.value}, 
					dataType: 'html', 
					timeout: 10000, 
					error: function(){
						//alert('Error loading PHP document');
						//alert("连接网络失败");
						return false;
					}, 
					success: function(result){
						result = result.replace(" ","");
						if (result == 'true'){
							//window.location.reload();
							window.location.href='member_case.php';
						} else {
							alert(result);
						};
					} 
				}); 
				return true;
			};
		} 
	});
	/*
	$.ajax({
		url: 'loginuser.php', 
		type: 'POST', 
		data:{username:input_username.value, password:input_password.value, code:input_code.value}, 
		dataType: 'html', 
		timeout: 10000, 
		error: function(){
			//alert('Error loading PHP document');
			//alert("连接网络失败");
			return false;
		}, 
		success: function(result){
			result = result.replace(" ","");
			if (result == 'true'){
				//window.location.reload();
				window.location.href='member_case.php';
			} else {
				alert(result);
			};
		} 
	}); 
	return true;
	*/
}

