



function selects(theInput)
{
	numchked=0;
	classID =theInput;
	for (i=0;i<classID.length;i+=1)
	if (classID[i].checked){ numchked=numchked+1;}
	if (numchked<1)
	{
		alert("对不起，请选择要操作的对象!");
		return false;
	}
	else
	return true;
}




function ifWesternChr(value) 
{  
	var chrInput_e; 
	for(i=0;i<value.length;i++ )
	{
		chrInput = value.charAt(i);
		chrInput_e=escape(chrInput); 
		if(chrInput_e.length==(chrInput.length)*6||chrInput=='\r'||chrInput=='\n')
		return false;
		else return true; 
	}
}
function isdigit(value)
{
  var checkOK = "0123456789";
  var allValid = true;

  if (value == "") return false;

  for (i = 0;  i < value.length;  i++)
  {
    ch = value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  return allValid;
}

function isTel(value)
{
	var checkOK = "-0123456789";
  var allValid = true;

  if (value == "") return false;

  for (i = 0;  i < value.length;  i++)
  {
    ch = value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  return allValid;
}

function scriptFilter(value)
{
//脚本过滤，返回true表示没有脚本语言,非法或者有脚本 返回false
	var checkOK = "<>";
	var allValid = true;
	
	if (value == "") return true;
	
	
	for (i = 0;  i < value.length;  i++)
	{
		ch = value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j)) return false;
	}
	return allValid;
}

function userNameFilter(value)
{ 
	if (value.indexOf(" ")>=0 ||value.indexOf(" ")>=0)
	{
		return false;
	}
	
  var checkOK = "0123456789abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var allValid = true;
  if (value == "") return false;
  for (i = 0;  i < value.length; i++)
  {
    ch = value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (ifWesternChr(value))
  {
  }
  else
 {
	  allValid=true
  }
return allValid;
}


function isdecimal(value)
{
  var checkOK = ".0123456789";
  var allValid = true;

  if (value == "") return false;

  for (i = 0;  i < value.length;  i++)
  {
    ch = value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  return allValid;
}

function isDate(a)
{
	var err=0
	var psj=0;

	c=a.indexOf("/");
	if(c==-1) return false;

	e=a.indexOf("/",c+1);
	if(e==-1) return false;

	b = a.substring(0, c);  // year
	d = a.substring(c+1,e); // month
	f = a.substring(e+1);   // day

	if (!isdigit(b)) return false;
	if (!isdigit(d)) return false;
	if (!isdigit(f)) return false;

	//basic error checking
	if (b<1900 || b>2050) err = 1
	if (d<1 || d>12) err = 1
	if (f<1 || f>31) err = 1

	//advanced error checking

	// months with 30 days
	if (d==4 || d==6 || d==9 || d==11){
		if (f==31) err=1
	}

	// february, leap year
	if (d==2){
		// feb
		var g=parseInt(b/4)
		if (isNaN(g)) {
			err=1
		}

		if (f>29) err=1
		if (f==29 && ((b/4)!=parseInt(b/4))) err=1
	}

	if (err==1){
		return false;
	}
	else{
		return true;
	}
}

function trim(srcStr)
{
	var i,j,len;
	len=srcStr.length;
	for(i=0;i<len;i++)
		if(srcStr.charAt(i)!=' ') break;
	for(j=len-1;j>=i;j--)
		if(srcStr.charAt(j)!=' ') break;

	if(i>j) return "";
	else return srcStr.substr(i,j-i+1);
}
function CheckForm(theForm)
{
	
   if (trim(theForm.cName.value).length < 2)
	{
	alert("对不起，请输入你的真实姓名（length>=2）！");
	 theForm.cName.focus();
	 return false;
	}

	if(ifWesternChr(theForm.cName.value))
	{
	 alert("对不起，真实姓名必须是中文！");
	 theForm.cName.focus();
	 return false;
	}
	
	if (theForm.passwd1.value!=theForm.passwd2.value)
	{alert("对不起，你两次输入的密码不相同！");
	 theForm.passwd1.focus();
	 return false;
	}

if (trim(theForm.passwd1.value).length<=5)
	{alert("对不起,密码长度必须大于5！");
	 theForm.passwd1.focus();
	 return false;
	}

if (theForm.Tiptopxw.value == "0")
	{alert("对不起，请填好你的学位！"); 
	 theForm.Tiptopxw.focus();
	 return false;
	}

if( theForm.birthday.value=="")
	{
	alert("请选择你的生日!");
	theForm.birthday.focus();
	return false;
	}
if( theForm.startYear.value==0||theForm.endYear.value==0)
	{
	alert("请正确选择入学和毕业年份！");
	theForm.startYear.focus();
	return false;
	}

	 if(theForm.graduationDepartment.value.length<2)
	{
	alert("请选择毕业院系！");
	theForm.graduationDepartment.focus();
	return false;
 }
if(trim(theForm.WorkEnterprise.value).length<3)
		{
	alert("请正确填写你的工作单位！");
	theForm.WorkEnterprise.focus();
	return false;
}
if(trim(theForm.Tele.value).length<8)
		{
	alert("请填写你的电话！");
	theForm.Tele.focus();
	return false;
}
if(!isTel(theForm.Tele.value))
		{
	alert("电话输入有误");
	theForm.Tele.focus();
	return false;
}
if(trim(theForm.mobileCode.value).length<11)
		{
	alert("请正确填写您的手机");
	theForm.mobileCode.focus();
	return false;
}	
if(!isdigit(theForm.mobileCode.value))
		{
	alert("手机号码填写有误！");
	theForm.mobileCode.focus();
	return false;
}

 
if (theForm.question.value.length < 1)
	{alert("对不起，请填好你的提问（length>=1）！");
	 theForm.question.focus();
	 return false;
	}
if (theForm.answer.value.length < 1)
	{alert("对不起，请填好你的答案（length>=1）！");
	 theForm.answer.focus();
	 return false;
	}
if (theForm.Email.value.length < 11 || theForm.Email.value.indexOf("@")<1 ||theForm.Email.value.indexOf("@")==theForm.Email.value.length-1)
	{alert("对不起，请填好你的Email！");
    theForm.Email.focus();
	 return false;	
	 }
 

theForm.submit();
return false;
}


