﻿﻿function trim(inputString) {
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	}
	return retValue;
}

function cc(theForm) { 

if (trim(theForm.company.value)=="")
{
	alert("請填寫聯繫地址");
	theForm.company.focus();
	theForm.company.select();
	return false;
}

if (trim(theForm.linkman.value)=="")
{
	alert("請填寫聯繫人");
	theForm.linkman.focus();
	theForm.linkman.select();
	return false;
}
if (trim(theForm.email.value)=="")
{
	alert("請填寫電子郵件");
	theForm.email.focus();
	theForm.email.select();
	return false;
}
var str1 = theForm.email.value
if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1)
{
	alert("電子郵件格式不正確,請重新填寫");
	theForm.email.focus();
	theForm.email.select();
	return false;
}

if (trim(theForm.phone.value)=="")
{
	alert("請填寫聯繫電話");
	theForm.phone.focus();
	theForm.phone.select();
	return false;
}


if (trim(theForm.content.value)=="")
{
	alert("請填寫留言内容");
	theForm.content.focus();
	theForm.content.select();
	return false;
}

theForm.submit();
return true;
}