﻿function validate(theForm) 
{
		if (theForm.TenNguoiGui.value == "")
  			{
				alert("Please enter company name. Thanks !");
				theForm.TenNguoiGui.focus();
				return (false);
  			}

		if (theForm.SoDienThoai.value == "")
  		{
			alert("Please enter your telephone. Thanks !");	
			theForm.SoDienThoai.focus();
			return (false);
 		}


//////////
function isDigit (c)
{
    var test = '' + c;
    if (test == '0' || test == '1' || test == '2' || test == '3' || test == '4' 
    		|| test == '5' || test == '6' || test == '7' || test == '8' || test == '9')
        {
	        return true;
        }
    return false;
}

var c;
l = theForm.SoDienThoai.value.length;
var i=0;
var Fail = false;

while (i<l && !Fail)
{
	c = theForm.SoDienThoai.value.substring(i,i+1)
	if ( isDigit(c) == false && c!= '.' && c!='+' && c!='-' && c!=' ' ) {	 
		Fail = true;
	}
	i++;
}

		if (Fail)
  		{
			alert("Please enter your telephone 0 1 2 3 4 5 6 7 8 9 . + - Thanks");	
			theForm.SoDienThoai.value = ""; Fail= false;
			theForm.SoDienThoai.focus();
			return (false);
 		}
 		

////////////


  			
		if (theForm.DiaChiEMail.value == "")
  			{
				alert("Please enter your email. Please !");
				theForm.DiaChiEMail.focus();
				return (false);
  			}  
  			
		if (theForm.DiaChiEMail.value != "")
	  	{
			if (theForm.DiaChiEMail.value.indexOf('@', 0) == -1 || theForm.DiaChiEMail.value.indexOf('.', 0) == -1)
			{
				alert("Please enter your email. Please !");
				theForm.DiaChiEMail.focus();
				return (false);
			}
  		}
			 
  	  
  	return (true);
}

