//检查表单
function checkForm(){
/*	if(document.frm.loginid.value.length==0){
		alert("用户名不能为空");
		document.frm.loginid.focus();
		return false;
	}else{
		if(/[^0-9a-zA-Z_]/g.test(document.frm.loginid.value)){
			alert("用户名只能由字母和数字、下划线组成");
			document.frm.loginid.focus();
			return false;		
		}
	}
*/
	if(document.frm.password.value.length>0){
		if(document.frm.password.value.length<6 || document.frm.password.value.length>16){
			alert("密码必须长度6～16位");
			document.frm.password.focus();
			return false;		
		}else{
			if(document.frm.password.value!=document.frm.password1.value){
				alert("您两次输入的密码不一样！请重新输入");
				document.frm.password1.focus();
				return false;			
			}
		}
	}
	if(!ismail(document.frm.email.value)){
		alert("邮箱输入不正确");
		document.frm.email.focus();
		return false;	
	}
    if(document.frm.dt_birthdate.value.length>0)
	  if(!strDateTime(document.frm.dt_birthdate.value)){
		  alert("出生日期格式有误！");
		  document.frm.dt_birthdate.focus();
		  return false;
		}

	if(document.all.register_tr.style.display=="" && document.frm.registercode.value.length==0){
		alert("验证码不能为空");
		document.frm.registercode.focus();
		return false;	
	}	
	return true;
}
//短日期
function strDateTime(str) 
{ 
	var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
	if(r==null)return false; 
	var d= new Date(r[1], r[3]-1, r[4]); 
	return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]); 
} 
//验证email
function ismail(mail) 
{ 
return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
} 

//验证用户名是否存在
function checkloginid(){
	if(document.frm.loginid.value.length==0){
		alert("请先输入用户名");
		document.frm.loginid.focus();
		return ;
	}	
	xml = new ActiveXObject("Microsoft.XMLHTTP"); 
	var post=" ";//构造要携带的数据 
	xml.open("POST","reg_checkloginid.jsp?loginid="+document.frm.loginid.value,false);//使用POST方法打开一个到服务器的连接，以异步方式通信 
	xml.setrequestheader("content-length",post.length); 
	xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
	xml.send(post);//发送数据 
	var res = xml.responseText;//接收服务器返回的数据 
	document.all.checklogin.innerHTML = res;
}
