﻿function CheckUserName(theform)		//----Choose an account ID and check if it is usable.
{
	if (!checkvalue4reg(theform.txtAccount,4,70,32,"帐号"))	return false;
	if (!CheckIfEnglish4Reg(theform.txtAccount.value))
	{
		alert("通行证只能由小写字母和数字和邮箱组成!");
		theform.txtAccount.focus();
		theform.txtAccount.select();
		return false;
	}
	/*if (!checkvalue(theform.txtAccount,4,15,32,"帐号"))	return false;
	if (!CheckIfEnglish(theform.txtAccount.value))
	{
		alert("帐号必须由字母和数字组成!");
		theform.txtAccount.focus();
		theform.txtAccount.select();
		return false;
	}*/
}


function CheckRegStep1(theform)
{
	if( typeof(theform.isAgreement)!="undefined" && theform.isAgreement.checked==false )
	{
		alert("请确认您已阅读并同意注册条款!");
		return false;
	}	
	
	if (!checkvalue4reg(theform.txtAccount,4,70,32,"帐号"))	return false;
	if (!CheckIfEnglish4Reg(theform.txtAccount.value))
	{
		alert("通行证只能由小写字母和数字和邮箱组成!");
		theform.txtAccount.focus();
		theform.txtAccount.select();
		return false;
	}
	
	/*if (!checkvalue(theform.txtAccount,4,15,32,"帐号"))	return false;
	if (!CheckIfEnglish(theform.txtAccount.value))
	{
		alert("帐号必须由字母和数字组成!");
		theform.txtAccount.focus();
		theform.txtAccount.select();
		return false;
	}*/

	if (!checkvalue(theform.txtPassword,6,14,32,"用户密码"))	return false;
	if (!CheckIfEnglish(theform.txtPassword.value))
	{
		alert("用户密码必须由字母和数字组成!");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
	if (!checkvalue(theform.txtConfirmPassword,6,14,32,"确认密码"))	return false;
	if (!CheckIfEnglish(theform.txtConfirmPassword.value))
	{
		alert("确认密码必须由字母和数字组成!");
		theform.txtConfirmPassword.focus();
		theform.txtConfirmPassword.select();
		return false;
	}	
	if(theform.txtPassword.value!=theform.txtConfirmPassword.value)
	{
		alert("两次输入的密码不一致!");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
	
	if (!checkvalue(theform.txtEmail,0,40,32,"邮箱地址"))	return false;
	
	if (!checkemail(theform.txtEmail.value))
	{
		alert("邮箱地址不合法!");
		theform.txtEmail.focus();
		theform.txtEmail.select();
		return false;
	}
	if (theform.txtEmail.value!=theform.txtConfirmEmail.value)
	{
		alert("两次输入的邮箱地址不一致!");
		theform.txtEmail.focus();
		theform.txtEmail.select();
		return false;
	}
	
	if (!checkvalue(theform.txt_realname,0,14,32,"真实姓名"))	return false;
	
	if(theform.txtPaperCard.value.length > 0)
	{
		if (theform.txtPaperCard.value.length != 15 && theform.txtPaperCard.value.length != 18 )
		{
			alert("请输入合法的身份证!");
			theform.txtPaperCard.focus();
			theform.txtPaperCard.select();
			return false;
		}
	}
}

function CheckRegStep2(theform)
{
	//if (!checkvalue(theform.txt_realname,0,14,32,"真实姓名"))	return false;
	if (!checkvalue(theform.txt_question,0,30,32,"密保问题"))	return false;
	if (!checkvalue(theform.txt_answer,4,30,32,"密保答案"))	return false;
	
	
	if (theform.txt_answer.value!=theform.txt_confirmanswer.value)
	{
		alert("两次输入的密保答案不一致!");
		theform.txtEmail.focus();
		theform.txtEmail.select();
		return false;
	}
}


function CheckResetPassword(theform)
{
	if (!checkvalue(theform.txtPassword,6,14,32,"用户密码"))	return false;
	if (!CheckIfEnglish(theform.txtPassword.value))
	{
		alert("用户密码必须是字母和数字的组合！");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
	if (!checkvalue(theform.txtCPassword,6,14,32,"确认密码"))	return false;
	if (!CheckIfEnglish(theform.txtCPassword.value))
	{
		alert("确认密码必须是字母和数字的组合！");
		theform.txtCPassword.focus();
		theform.txtCPassword.select();
		return false;
	}	
	if(theform.txtPassword.value!=theform.txtCPassword.value)
	{
		alert("两次输入的密码不一致！");
		theform.txtPassword.focus();
		theform.txtPassword.select();
		return false;
	}
}