<!--
$(document).ready(function()
{
 
	//checkSubmit
	$('#regUser').submit(function ()
	{
		if(!$('#agree').get(0).checked) {
			alert("你必须同意注册协议！");
			return false;
		}
		if($('#txtUsername').val()==""){
			$('#txtUsername').focus();
			alert("用户名不能为空！");
			return false;
		}
		if( isNumber($('#txtUsername').val().substring(0,1))){
			$('#txtUsername').focus();
			alert("用户名不能以数字开头,必须以英文开头！");
			return false;
		}
		
		
		
		if($('#txtPassword').val()=="")
		{
			$('#txtPassword').focus();
			alert("登陆密码不能为空！");
			return false;
		}
		if($('#userpwdok').val()!=$('#txtPassword').val())
		{
			$('#userpwdok').focus();
			alert("两次密码不一致！");
			return false;
		}
		if(!checkIsIntegerstr($('#txtPassword').val()))
		{
			$('#userpwdok').focus();
			alert("密码只能是字母和数字！");
			return false;
		}
		
		
		 if($('#email').val()=="")
		{
			$('#email').focus();
			alert("电子邮箱不能为空！");
			return false;
		}
		
		if($('#birthday').val()=="")
		{
			$('#birthday').focus();
			alert("出生日期不能为空！");
			return false;
		}
		
		if(isDate($('#birthday').val())==false)
		{
			$('#birthday').focus();
			alert("出生日期格式不对！");
			return false;
		}
		
	
		
		
		if($('#vdcode').val()=="")
		{
			$('#vdcode').focus();
			alert("验证码不能为空！");
			return false;
		}
	})
	
	//AJAX changChickValue
	$("#txtUsername").change( function() {
		$.ajax({type: reMethod,url: "index_do.php",
		data: "dopost=checkuser&fmdo=user&cktype=1&uid="+$("#txtUsername").val(),
		dataType: 'html',
		success: function(result){$("#_userid").html(result);}}); 
	});
	
	/*
	$("#uname").change( function() {
		$.ajax({type: reMethod,url: "index_do.php",
		data: "dopost=checkuser&fmdo=user&cktype=0&uid="+$("#uname").val(),
		dataType: 'html',
		success: function(result){$("#_uname").html(result);}}); 
	});
	*/
	
	$("#email").change( function() {
		var sEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		if(!sEmail.exec($("#email").val()))
		{
			$('#_email').html("<font color='red'><b>×Email格式不正确</b></font>");
			$('#email').focus();
		}else{
			$.ajax({type: reMethod,url: "index_do.php",
			data: "dopost=checkmail&fmdo=user&email="+$("#email").val(),
			dataType: 'html',
			success: function(result){$("#_email").html(result);}}); 
		}
	});	
	
	$('#txtPassword').change( function(){
									   
		if($('#txtPassword').val().length < 6)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+6+"位</b></font>");
		}
		else if($('#txtPassword').val().length > 20)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能大于"+20+"位</b></font>");
		}
		else if(!checkIsIntegerstr($('#txtPassword').val()))
		{
			$('#_userpwdok').html("<font color='red'><b>×密码只能是字母和数字</b></font>");
		}
		
		else if($('#userpwdok').val()!=$('txtPassword').val())
		{
			$('#_userpwdok').html("<font color='red'><b>×两次输入密码不一致</b></font>");
		}
		else if($('#userpwdok').val().length < 6)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+6+"位</b></font>");
		}
		else if($('#userpwdok').val().length >20 )
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能大于"+20+"位</b></font>");
		}
		else
		{
			$('#_userpwdok').html("<font color='#4E7504'><b>√填写正确</b></font>");
		}
	});
	
	$('#userpwdok').change( function(){
		if($('#txtPassword').val().length < 6)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能小于"+6+"位</b></font>");
		}
		
		else if($('#txtPassword').val().length >20)
		{
			$('#_userpwdok').html("<font color='red'><b>×密码不能大于"+20+"位</b></font>");
		}
		else if(!checkIsIntegerstr($('#txtPassword').val()))
		{
			$('#_userpwdok').html("<font color='red'><b>×密码只能是字母和数字</b></font>");
		}
		else if($('#userpwdok').val()=='')
		{
			$('#_userpwdok').html("<b>请填写确认密码</b>");
		}
		else if($('#userpwdok').val()!=$('#txtPassword').val())
		{
			$('#_userpwdok').html("<font color='red'><b>×两次输入密码不一致</b></font>");
		}
		else
		{
			$('#_userpwdok').html("<font color='#4E7504'><b>√填写正确</b></font>");
		}
	});
	
	$("a[href*='#vdcode'],#vdimgck").bind("click", function(){
		$("#vdimgck").attr("src","../include/vdimgck.php?tag="+Math.random());
		return false;
	});
});


    function checkIsIntegerstr(str) 
        { 
                //如果为空，则通过校验 
                if(str == "") 
               return false; 
               if(/^[A-Za-z0-9]+$/.test(str)) 
               return true; 
             else 
               return false; 
         } 

function isDate(str){
 var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/
 if (reg.test(str)){
  return true;
 }
 return false;
}

function isNumber(str){ 
if(""==str){ 
return false; 
} 
var reg = /\D/; 
return str.match(reg)==null; 
} 

-->