	function validateForm(lang) {
		if (checkfieldCns(document.register.txtName, 's', 0, true, 'Name','ชื่อ',lang)==false) {
			document.register.txtName.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtSurname, 's', 0, true, 'Lastname','นามสกุล',lang)==false) {
			document.register.txtSurname.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtAddress, 's', 0, true, 'Address','ที่อยู่สำหรับการติดต่อ',lang)==false) {
			document.register.txtAddress.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtCity, 's', 0, true, 'City','เขต/อำเภอ',lang)==false) {
			document.register.txtCity.focus();
			return false;
		}
		if (document.register.txtState.value == '0') {
			if(lang == 'en')
				alert("Please select Province");
			else 
				alert("กรุณาเลือกจังหวัด");
			document.register.txtState.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtPostCode, 'n', 5, true, 'Post Code','รหัสไปรษณีย์',lang)==false) {
			document.register.txtPostCode.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtCountry, 's', 0, false, 'Country','ประเทศ',lang)==false) {
			document.register.txtCountry.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtPhone1, 'n', 4, true, 'Phone Number','โทรศัพท์',lang)==false) {
			document.register.txtPhone1.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtPhone2, 'n', 4, true, 'Phone Number','โทรศัพท์',lang)==false) {
			document.register.txtPhone2.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtPhoneExt, 'n', 0, false, 'Phone Number','โทรศัพท์',lang)==false) {
			document.register.txtPhoneExt.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtMobile1, 'n', 4, true, 'Mobile Number','โทรศัพท์มือถือ',lang)==false) {
			document.register.txtMobile1.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtMobile2, 'n', 4, true, 'Mobile Number','โทรศัพท์มือถือ',lang)==false) {
			document.register.txtMobile2.focus();
			return false;
		}
		if (document.register.txtOccupation.value == '000') {
			if(lang == 'en')
				alert("Please select Occupation");
			else 
				alert("กรุณาเลือกอาชีพ");
			document.register.txtOccupation.focus();
			return false;
		}
		if (document.register.txtKnowWebsite.value == '000') {
			if ((document.register.txtKnowCns[0].checked || document.register.txtKnowCns[1].checked || document.register.txtKnowCns[2].checked || document.register.txtKnowCns[3].checked) == false) {
				if(lang == 'en')
					alert("Please choose \"How do you know CNS?\"");
				else 
					alert("กรุณาเลือก \"ท ่านรู้จัก CNS ได้อย่างไร ?\"");
				return false;
			}
		}
		if(document.register.txtKnowCns[3].checked && document.register.txtKnowCnsEtc.value == '') {
			if(lang == 'en')
				alert("Please choose \"How do you know CNS?\"");
			else 
				alert("กรุณาเลือก \"ท ่านรู้จัก CNS ได้อย่างไร ?\"");
			document.register.txtKnowCnsEtc.focus();
			return false;
		}
		if (checkUserAndPassword(document.register.txtLoginId)==false) {
			if(lang == 'en')
				alert("User login name incorrect");
			else 
				alert("ชื่อผู้ใช้บริการ ไม่ตรงตามรูปแบบที่กำหนด");
			document.register.txtLoginId.focus();
			return false;
		}
		if (checkUserAndPassword(document.register.txtPswd)==false) {
			if(lang == 'en')
				alert("Password incorrect");
			else 
				alert("รหัสผ่าน ไม่ตรงตามรูปแบบที่กำหนด");
			document.register.txtPswd.focus();
			return false;
		}
		if (checkUserAndPassword(document.register.txtPswd1)==false) {
			if(lang == 'en')
				alert("Password incorrect");
			else 
				alert("รหัสผ่าน ไม่ตรงตามรูปแบบที่กำหนด");
			document.register.txtPswd1.focus();
			return false;
		}
		if (validpswd(document.register.txtPswd, document.register.txtPswd1)==false) {
			document.register.txtPswd.focus();
			return false;
		}
		if (document.register.txtQuestion.value == '000') {
			if(lang == 'en')
				alert("Please select secret question");
			else 
				alert("กรุณาเลือกคำถามกันลืม");
			document.register.txtQuestion.focus();
			return false;
		}
		if (document.register.txtQuestion.value == '006') {
			if (checkfieldCns(document.register.txtQuestion1, 's', 0, true, 'Question','คำถามกันลืม',lang)==false) {
				document.register.txtQuestion.focus();
				return false;
			}
		}
		if (checkfieldCns(document.register.txtAnswer, 's', 0, true, 'Answer','คำตอบ',lang)==false) {
			document.register.txtAnswer.focus();
			return false;
		}
		if (checkfieldCns(document.register.txtEmailAddr, 's', 0, true, 'Email','อีเมล์',lang)==false) {
			document.register.txtEmailAddr.focus();
			return false;
		}
		if ((document.register.txtService[0].checked || document.register.txtService[1].checked || document.register.txtService[2].checked) == false) {
			if(lang == 'en')
				alert("Please choose your interest service");
			else 
				alert("กรุณาเลือกบริการที่ท่านสนใจ");
			return false;
		}
		return true;
	}
	
	function validateLogin() {    	
		if (checkfield(document.frmLogin.txtLogin,'s',0,true,'Login')==false) {
			return false;     
		}    	
		if (checkpassword(document.frmLogin.txtPassword,'s',true,'Password')==false) {
			return false;
		}    
		return true;
	}
	function validateForgotPassword(lang) {    	
		//if (document.forgotpwd.question1.value == '000') {
		//	if(lang == 'en')
		//		alert("Please select secret question");
		//	else 
		//		alert("กรุณาเลือกคำถามกันลืม");
		//	return false;
		//}
		//if (document.forgotpwd.question1.value == '006') {
		//	if (checkfield(document.forgotpwd.question2, 's', 0, true, 'คำถามกันลืมอื่นๆ')==false) {
		//		return false;
		//	}
		//}
		if (checkfield(document.forgotpwd.answer,'s',0,true,'Answer')==false) {
			return false;     
		}    	
		if (checkUserAndPassword(document.forgotpwd.newPwd1)==false) {
			if(lang == 'en')
				alert("Password incorrect");
			else 
				alert("รหัสผ่าน ไม่ตรงตามรูปแบบที่กำหนด");
			return false;
		}    
		if (validpswd(document.forgotpwd.newPwd1, document.forgotpwd.newPwd2)==false) {
			return false;
		}
		return true;
	}
	function validateExpireAccount(lang) {
		if (checkfield(document.freetrial_continue.txtUsername,'s',0,true,'Username')==false) {
			return false;     
		}
		if (checkpassword(document.freetrial_continue.txtPasswd,'s',true,'Password')==false) {
			return false;
		}
		if ((document.freetrial_continue.txtService[0].checked || document.freetrial_continue.txtService[1].checked || document.freetrial_continue.txtService[2].checked) == false) {
			if(lang == 'en')
				alert("Please choose your interest service");
			else 
				alert("กรุณาเลือกบริการที่ท่านสนใจ");
			return false;
		}
		return true;
	}
	
	function checkUserAndPassword(field) {
		var objRegex = new RegExp("^[a-zA-Z0-9]{6,10}$");
		return objRegex.test(field.value);
	}
	
	function checkfieldCns(field1, type1, nlen, chknull, fname,tname,lang) {
		var   isvalid =true
	
		if (chknull) {
			if (field1.value == null || field1.value == "") {
				if(lang == 'en')
					alert(fname + " requires a value.")
				else 
					alert("กรุณาใส่" + tname);
				isvalid=false
			}
		}
	
		strVal=field1.value;
		if (nlen != 0 && isvalid==true) {
			if (strVal.length < nlen) {
				//alert(fname + " minimum " + nlen + " of character.")
				if(lang == 'en')
					alert(fname + " minimum " + nlen + " of character.")
				else 
					alert("ความยาวของ" + tname + "ไม่ถูกต้อง");
				isvalid=false
			}   
		}       
	
		if (type1 == "n" && isvalid==true) {
			if (!isNumber(field1.value, false, true)) {
				if(lang == 'en')
					alert("Invalid positive number for " + fname)
				else 
					alert(tname + "ไม่ถูกต้อง")
				isvalid=false
			}
		}
		//------------------tested------------------------------------------//
		if (isvalid==true) {
			if (field1.type == "text") {
				field1.focus()
			}
			return true
		} else {
			return false
		}
	}