﻿function trim(inputString) {

	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		//Check space of begin
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		//Check space of ending
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
		//Replace multi-space
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	}
	return retValue;
}

function cc(theForm) { 


if (trim(theForm.linkman.value)=="")
{
alert("Please fill Contacts");
theForm.linkman.focus();
theForm.linkman.select();
return false;
}
if (trim(theForm.company.value)=="")
{
alert("Please fill in the company name");
theForm.company.focus();
theForm.company.select();
return false;
}
if (trim(theForm.address.value)=="")
{
alert("Please fill in address");
theForm.address.focus();
theForm.address.select();
return false;
}
if (trim(theForm.phone.value)=="")
{
alert("Please Fill in telephone");
theForm.phone.focus();
theForm.phone.select();
return false;
}
if (trim(theForm.email.value)=="")
{
alert("Please fill in e-mail");
theForm.email.focus();
theForm.email.select();
return false;
}
var str1 = theForm.email.value
if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1){
alert("E-mail format is not correct, please fill out");
theForm.email.focus();
theForm.email.select();
return false;
}
if (trim(theForm.content.value)=="")
{
alert("Suggestions can not be empty");
theForm.content.focus();
theForm.content.select();
return false;
}
if (trim(theForm.Verifycode.value)=="")
{
alert("Verification Code can not be empty");
theForm.Verifycode.focus();
theForm.Verifycode.select();
return false;
}

return true;
 
}