﻿//<!--
function validfield() 
{
	//Check general fields
	//check First Name field
	if (document.request.name.value == "") { alert ("请输入您的姓名。"); document.request.name.focus();	return false; }
	
	//check Last Name field
	//if (document.request.lname.value == "") { alert ("Please enter your Last/Family Name."); document.request.lname.focus(); return false; }
	
	//check Email field
	var emailvalue = document.request.email.value;		 	 
   	if (emailvalue == "") { alert ("请输入您的邮件地址。"); document.request.email.focus(); return false; }
   	//if (emailvalue != "") { alert(emailvalue); }
   	//if ((emailvalue.indexOf ('@') == -1) || (emailvalue.indexOf ('.') == -1)) {
   	if ((emailvalue.indexOf ('@', 2) == -1) || (emailvalue.indexOf ('.', 4) == -1)) {
		alert('请输入正确的邮件地址 (e.g yourname\@yourcompany.com)。');  
        document.request.email.focus(); document.request.email.select();
		return false;
	}
   	// an at sign (@) that at least the third character and a period (.) that is at least the fifth character 
	
	//2 (@) signs not allowed  - working but a bit unclear - is the "2" needed after the '@ sign'?
	/*atPos = emailvalue.indexOf ('@', 2);
	if (emailvalue.indexOf ('@',atPos+1) > 1) { alert('Please enter one e-mail address.'); document.request.email.focus(); return false;  }
	*/  //2 (@) signs not allowed  - working but a bit unclear - is the "2" needed after the '@ sign'?
	
	var index = emailvalue.indexOf("@");
	index = emailvalue.indexOf("@",index+1);
	
	//added comma,semicolon validation
	indexcomma = emailvalue.indexOf(",");
	indexsemicolon = emailvalue.indexOf(";");
	
	if((index !=-1) || (indexcomma > 0 )|| (indexsemicolon> 0 )){
		alert("请输入只一个邮件地址。");
		document.request.email.focus();
		return false;
	}
	
	//check Area of Interest checkboxes
	chkbx1 =  document.request.ts_alert.checked;
	chkbx2 =  document.request.case_export.checked;
	chkbx3 =  document.request.research_csr.checked;
	chkbx4 =  document.request.export_edu.checked;
		
	if ((chkbx1) || (chkbx2) || (chkbx3) || (chkbx4) == true ) { document.request.ts_alert.focus();}
	else { alert("请选择您感兴趣的资料。"); document.request.ts_alert.focus(); return false; }
	
 return true;
}

//-->