//验证是否身份证
function IsIdnum(str)
{
 var City={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",
     31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",
     43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",
     61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "}
 var iSum=0
 var info=""
 if(!/^\d{17}(\d|x)$/i.test(str))
  return false;
 str=str.replace(/x$/i,"a");
 if(City[parseInt(str.substr(0,2))]==null)
 {
  alert( "身份证错误:非法地区");
  return false;
 }
 sBirthday=str.substr(6,4)+"-"+Number(str.substr(10,2))+"-"+Number(str.substr(12,2));
 var d=new Date(sBirthday.replace(/-/g,"/"))
 if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
 {
  alert("身份证错误:非法生日");
  return false;
 }
 for(var i = 17;i>=0;i --) 
  iSum += (Math.pow(2,i) % 11) * parseInt(str.charAt(17 - i),11)
 if(iSum%11!=1)
 {
  alert("身份证错误:非法证号");
  return false;
 }
 return City[parseInt(str.substr(0,2))]+","+sBirthday+","+(str.substr(16,1)%2?"男":"女")
}

//验证是否为中文
function IsChinese(str)
{
 var reg=/^[\u0391-\uFFE5]+$/;
 return reg.test(str);
}
// 判断字符由字母和数字组成。
function Is_letter_num(str)
{
 var reg=/[^0-9a-zA-Z]/g;
 return reg.test(str);
}
//验证是否未email
function IsEmail(str)
{
 var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
 return reg.test(str);
}
//验证固话。例：0757-12345678-123
function IsTelphone(str)
{
 var reg=/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/
    return reg.test(str);
}
//手机号码验证，验证13系列和158、159、188、189几种号码，长度11位
function IsMobel(str)
{
	var reg0 = /^13\d{9}$/;
    var reg1 = /^158\d{8}$/;
    var reg2 = /^159\d{8}$/;
    var reg3 = /^188\d{8}$/;
    var reg4 = /^189\d{8}$/;
    return (reg0.test(str)||reg1.test(str)||reg2.test(str)||reg3.test(str)||reg4.test(str))
}
//是否为由数字组成的字符串
function is_digitals(str)
{
 var reg=/^[0-9]*$/;//匹配整数
 return reg.test(str);      
}
//验证非法字符
function IsErrorInput(str)
{
	var reg = /^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
	return reg.test(str);
}

function checkForm(){
	if(!IsIdnum(form1.id.value))
	{
		alert("\"身份证\"填写有误");
		form1.id.focus();
		return false;
	}

	if(!IsChinese(form1.name.value))
	{
		alert("\"姓名\"填写有误");
		form1.name.focus();
		return false;
	}
	if (form1.birthday.value==""||form1.birthday.value==null)
	{
		alert("\"出生日期\"不得为空");
		form1.birthday.focus();
		return false;
	}
	if(!IsChinese(form1.origin.value))
	{
		alert("\"籍贯\"填写有误");
		form1.origin.focus();
		return false;
	}
	if (form1.account_location.value==""||form1.account_location.value==null)
	{
		alert("\"户口所在地\"不得为空");
		form1.account_location.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.account_location.value))
		{
			alert("\"户口所在地\"添写有误，请不要包含标点及特殊字符");
			form1.account_location.focus();
			return false;
		}
	}
	if(!IsEmail(form1.email.value))
	{
		alert("\"E-mail地址\"填写有误");
		form1.email.focus();
		return false;
	}

	if(!IsTelphone(form1.phone_1.value))
	{
		alert("\"家庭电话\"填写有误");
		form1.phone_1.focus();
		return false;
	}
	if(!IsMobel(form1.phone_2.value))
	{
		alert("\"手机\"填写有误");
		form1.phone_2.focus();
		return false;
	}
	if (form1.weight.value==""||form1.weight.value==null)
	{
		alert("\"体重\"不得为空");
		form1.weight.focus();
		return false;
	}else{
		if(!is_digitals(form1.weight.value))
		{
			alert("\"体重\"填写有误");
			form1.weight.focus();
			return false;
		}
	}
	if (form1.height.value==""||form1.height.value==null)
	{
		alert("\"身高\"不得为空");
		form1.height.focus();
		return false;
	}else{
		if(!is_digitals(form1.height.value))
		{
			alert("\"身高\"填写有误");
			form1.height.focus();
			return false;
		}
	}
	if (form1.features.value==""||form1.features.value==null)
	{
		alert("\"特长\"不得为空");
		form1.features.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.features.value))
		{
			alert("\"特长\"添写有误，请不要包含标点及特殊字符");
			form1.features.focus();
			return false;
		}
	}
	if (form1.education.value==-1)
	{
		alert("\"学历\"不得为空");
		form1.education.focus();
		return false;
	}
	if (form1.gra_time.value==""||form1.gra_time.value==null)
	{
		alert("\"毕业时间\"不得为空");
		form1.gra_time.focus();
		return false;
	}
	if (form1.graduate_school.value==""||form1.graduate_school.value==null)
	{
		alert("\"毕业院校\"不得为空");
		form1.graduate_school.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.graduate_school.value))
		{
			alert("\"毕业院校\"添写有误，请不要包含标点及特殊字符");
			form1.graduate_school.focus();
			return false;
		}
	}
	if (form1.professional.value==""||form1.professional.value==null)
	{
		alert("\"专业\"不得为空");
		form1.professional.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.professional.value))
		{
			alert("\"专业\"添写有误，请不要包含标点及特殊字符");
			form1.professional.focus();
			return false;
		}
	}
	if (form1.professional_category.value==-1)
	{
		alert("\"专业分类\"不得为空");
		form1.professional_category.focus();
		return false;
	}
	if (form1.is_teacher_pro.value==-1)
	{
		alert("\"专业类别\"不得为空");
		form1.is_teacher_pro.focus();
		return false;
	}
	if (form1.second_professional.value==""||form1.second_professional.value==null)
	{
		alert("\"第二专业\"不得为空");
		form1.second_professional.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.second_professional.value))
		{
			alert("\"第二专业\"添写有误，请不要包含标点及特殊字符");
			form1.second_professional.focus();
			return false;
		}
	}
	if (form1.school_sys.value==""||form1.school_sys.value==null)
	{
		alert("\"学制\"不得为空");
		form1.school_sys.focus();
		return false;
	}else{
		if(!is_digitals(form1.school_sys.value))
		{
			alert("\"学制\"填写有误");
			form1.school_sys.focus();
			return false;
		}
	}
	if(!IsChinese(form1.second_language.value))
	{
		alert("\"第二外语\"填写有误，请填写中文");
		form1.second_language.focus();
		return false;
	}
	if (form1.company_name.value!=""||form1.company_name.value!=null)
	{
		if(!IsErrorInput(form1.company_name.value))
			{
				alert("\"就业单位名\"添写有误，请不要包含标点及特殊字符");
				form1.company_name.focus();
				return false;
			}
	}
	if (form1.remarks.value!=""||form1.remarks.value!=null)
	{
		if(!IsErrorInput(form1.remarks.value))
			{
				alert("\"备注\"添写有误，请不要包含标点及特殊字符");
				form1.remarks.focus();
				return false;
			}
	}
	return true;
}

function chkSearchForm(){
	if (graSearch.professional.value==""||graSearch.professional.value==null)
	{
		alert("\"专业\"不能为空");
		graSearch.professional.focus();
		return false;
	}else{
		if(!IsErrorInput(graSearch.professional.value))
		{
			alert("\"备注\"添写有误，请不要包含标点及特殊字符");
			graSearch.professional.focus();
			return false;
		}
	}

	if (graSearch.gra_time.value==""||graSearch.gra_time.value==-1)
	{
		alert("\"毕业时间\"不能为空");
		graSearch.gra_time.focus();
		return false;
	}
	return true;
}

function chkGraLogin(){
	if (form1.username.value==""||form1.username.value==null)
	{
		alert("\"用户名\"不能为空");
		form1.username.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.username.value))
		{
			alert("\"用户名\"添写有误，请不要包含标点及特殊字符");
			form1.username.focus();
			return false;
		}
	}

	if (form1.password.value==""||form1.password.value==null)
	{
		alert("\"密码\"不能为空");
		form1.password.focus();
		return false;
	}else{
		if(!IsErrorInput(form1.password.value))
		{
			alert("\"密码\"添写有误，请不要包含标点及特殊字符");
			form1.password.focus();
			return false;
		}
	}
	return true;
}

function chkComLogin(){
	if (form2.username.value==""||form2.username.value==null)
	{
		alert("\"企业用户名\"不能为空");
		form2.username.focus();
		return false;
	}else{
		if(!IsErrorInput(form2.username.value))
		{
			alert("\"企业用户名\"添写有误，请不要包含标点及特殊字符");
			form2.username.focus();
			return false;
		}
	}

	if (form2.password.value==""||form2.password.value==null)
	{
		alert("\"密码\"不能为空");
		form2.password.focus();
		return false;
	}else{
		if(!IsErrorInput(form2.password.value))
		{
			alert("\"密码\"添写有误，请不要包含标点及特殊字符");
			form2.password.focus();
			return false;
		}
	}
	return true;
}
