function isValidPhoneNo(thestring)
{
	var OK=true;
	for(var i=0;i<thestring.length;i++)
	{
		thechar=thestring.charAt(i);
		if((thechar<"0") || (thechar>"9"))
		{
			if(!((thechar=="+") || (thechar=="(") || (thechar==")") || (thechar=="-") || (thechar==" ")))
			{
				OK=false;
				break;
			}
		}
	}
	return OK;
}
function validateEmail(mail)
{
	if(mail.indexOf("@")==-1 || mail.indexOf("@")==0 || (mail.indexOf("@")==(mail.length-1)))
		return false;
	if(mail.indexOf(".")==-1|| (mail.indexOf(".")==(mail.length-1))|| (mail.indexOf(".")-mail.indexOf("@")==1)|| (mail.indexOf(".")-mail.indexOf("@")==-1))
		return false;

	for(var i=0;i<mail.length;i++)
		if(mail.charAt(i)==" ")
			return false;
				
	return true;
}
function validateForm()
{
	with (document.myform)
	{
		if(txtname.value=="")
		{
			alert("please enter Name");
			txtname.focus();
			return false;
		}
		if(txtcompany.value=="")
		{
			alert("please enter Company");
			txtcompany.focus();
			return false;
		}
		if(txtphone.value=="")
		{
			alert("please enter Phone Number");
			txtphone.focus();
			return false;
		}
		if(!isValidPhoneNo(txtphone.value))
		{
			alert("Please enter valid Phone Number");
			txtphone.focus();
			return false;
		}
		if(txtemail.value=="")
		{
			alert("please enter Email Address");
			txtemail.focus();
			return false;
		}
		if(!validateEmail(txtemail.value))
		{
			alert("please enter valid Email Address");
			txtemail.focus();
			return false;
		}
		if(txtocity.value=="")
		{
			alert("please enter Original City");
			txtocity.focus();
			return false;
		}
		if(txtdcity.value=="")
		{
			alert("please enter Destination City");
			txtdcity.focus();
			return false;
		}
		if(txtnoofstop.selectedIndex=="0")
		{
			alert("please select No. of Stops");
			txtnoofstop.focus();
			return false;
		}
		if(txtnoofstop.selectedIndex=="2")
		{
			if(txtcity1.value=="")
			{
				alert("please enter City - 1");
				txtcity1.focus();
				return false;
			}
			if(txtstate1.value=="")
			{
				alert("please select State - 1");
				txtstate1.focus();
				return false;
			}
		}
		if(txtnoofstop.selectedIndex=="3")
		{
			if(txtcity1.value=="")
			{
				alert("please enter City - 1");
				txtcity1.focus();
				return false;
			}
			if(txtstate1.value=="")
			{
				alert("please select State - 1");
				txtstate1.focus();
				return false;
			}
			if(txtcity2.value=="")
			{
				alert("please enter City - 2");
				txtcity2.focus();
				return false;
			}
			if(txtstate2.value=="")
			{
				alert("please select State - 2");
				txtstate2.focus();
				return false;
			}
		}
		if(txtnoofstop.selectedIndex=="4")
		{
			if(txtcity1.value=="")
			{
				alert("please enter City - 1");
				txtcity1.focus();
				return false;
			}
			if(txtstate1.value=="")
			{
				alert("please select State - 1");
				txtstate1.focus();
				return false;
			}
			if(txtcity2.value=="")
			{
				alert("please enter City - 2");
				txtcity2.focus();
				return false;
			}
			if(txtstate2.value=="")
			{
				alert("please select State - 2");
				txtstate2.focus();
				return false;
			}
			if(txtcity3.value=="")
			{
				alert("please enter City - 3");
				txtcity3.focus();
				return false;
			}
			if(txtstate3.value=="")
			{
				alert("please select State - 3");
				txtstate3.focus();
				return false;
			}
		}
	}
	return true;
}