var formSubmitted = false;
function Validate(theForm)
{
	var errMesg = "";
	var diplayMesg = "";
	// Check all the Required Information fields.
	//{
	var Q = ""; // this block determines lifespan of Q
	
	
	if (isWhitespace(theForm.name.value))
	{
		Q += "  Name\n";
	}
	
	if (isWhitespace(theForm.address.value))
	{
		Q += "  Address\n";
	}	
	else if(theForm.address.value.length>500)
	{
		errMesg += "Address should not be greater than 500 characters\n";
	}
		
	if (isWhitespace(theForm.phone.value))
	{
		Q += "  Phone\n";
	}
	else if(!isCharsInBag(theForm.phone.value,"0123456789- "))
	{
	  errMesg += "Phone contains Invalid Characters\n";
	}
	if (isWhitespace(theForm.email.value))
	{
		Q += "  Email \n";
	}
	else if(echeck(theForm.email.value))
	{
	   errMesg += "Invalid Email Address\n";
	}	
	else if(!isCharsInBag( theForm.email.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
	{
	  errMesg += "Email Address contains Invalid Characters\n";
	}
	if (isWhitespace(theForm.code.value))
	{
		Q += "  Security Code\n";
	}
	
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide Valid values for\n" + Q ;
		//errMesg += "Please provide Valid values for\n" + Q ;
	
	}
	
	if (errMesg == "" && diplayMesg == "")
	{
		if(formSubmitted == false) {
			formSubmitted = true;
			return true;
		}
		else {
			alert('Your transaction is in progress. Please wait !');
		}
	}
	
	else
	{
		if(diplayMesg!="")
		{
			alert(diplayMesg);
			return false;			
		}
		else
		{
			alert(errMesg);
			return false;
		}	
	}
}
	

	
