//VALIDATION FOR FORM

function Data(name,email,phone,fax,street_address,city,state,zip,country,city_car_reqd,Type_of_Car,car_standard,from_dd,from_mm,from_yy,to_dd,to_mm,to_yy,description)
{
	var name,email,phone,fax,street_address,city,state,zip,country,city_car_reqd,Type_of_Car,car_standard,from_dd,from_mm,from_yy,to_dd,to_mm,to_yy,description;
	
	name=theform.name.value;
	email=theform.email.value;
	phone=theform.phone.value;
	fax=theform.fax.value;
	street_address=theform.street_address.value;
	city=theform.city.value;
	state=theform.state.value;
	zip=theform.zip.value;
	country=theform.country.value;
        city_car_reqd=theform.city_car_reqd.value;
	Type_of_Car=theform.Type_of_Car.value;
	car_standard=theform.car_standard.value;
	from_dd=theform.from_dd.value;
	from_mm=theform.from_mm.value;
	from_yy=theform.from_yy.value; 
	to_dd=theform.to_dd.value;       
	to_mm=theform.to_mm.value;
	to_yy=theform.to_yy.value;
	description=description.value;

	if(nullValue(name)==0|| nullValue(email)==0 || nullValue(phone)==0|| nullValue(fax)==0 || nullValue(street_address)==0 || nullValue(city)==0 || nullValue(state)==0 || nullValue(zip)==0 || nullValue(country)==0 || nullValue(city_car_reqd)==0 || nullValue(Type_of_Car)==0 || nullValue(car_standard)==0 || nullValue(from_dd)==0 || nullValue(from_mm)==0 || nullValue(from_yy)==0 || nullValue(to_dd)==0 || nullValue(to_mm)==0 || nullValue(to_yy)==0 || nullValue(description)==0)
	{
		//FNAME - UID - EMAIL -----CAN'T BE BLANK
		alert("You Have Left Any Of The COMPULSORY Field Blank!");
		return false;
	}

	
	if(checkEmail(email)==0)
	{
		alert("Invalid E-Mail Address");
		document.forms[0].email.focus();
		return false;
	}

}

//-------------CHECKING ANY NULL VALUE

function nullValue(num)
	{var str;
	str=num;
		if(str == 0)
		{
			return 0; 
		}
		else
		{
			return 1;
		}

	}
//-----------CHECKING FOR ONLY ALPHAETS

function checkOnlyAlpha(char)
{
	var v=char;
	var i;
	i=v.length;
	var ctr,temp,dump;
	for(ctr=0;ctr<=i;ctr++)
	{
		dump=v.charAt(ctr);
		temp=dump.charCodeAt(0);//Returns the Unicode encoding of the specified character.
					//stringObj.charCodeAt(index).(stringObj)A String object or literal. 
					//(index )The zero-based index of the specified character.  
	
		if(temp<'65'||temp>'90')
		{
			if(temp<'97'||temp>'122')
			{
				return 0;
			}
		}
	}
}


//-------------------CHECKING FOR ANY INVALID CAHRACTER VALUE IN THE eMAIL

function checkEmail(char)
{
	var val=char;
	var len=val.length;
	var ctr,temp,cat,dot=0,goForApproval=0,haveJunk=0;
	var atTheRate=0;
	for(ctr=0;ctr<len;ctr++)
	{
		temp=val.charAt(ctr);
		cat=temp.charCodeAt(0);
		if(cat<'65'||cat>'90')
		{
			if(cat<'97'||cat>'122')
			{
				if(cat<'48'||cat>'57')
				{			
					if(cat=='64')	//@ has ASCII value of 64
					{
						atTheRate+=1;
						goForApproval=1;
						haveJunk=0;
					}
					else
					if(cat=='46')	//. has ASCII value of 46
					{
						dot+=1;
						goForApproval=1;
						haveJunk=0;
					}
					else
					if(cat=='95')	//_ has ASCII value of 95
					{
						goForApproval=1;
						haveJunk=0;
					}
					else
					{haveJunk=1;break;}			
				}
			}	
		}
	}
	if(goForApproval==1 && haveJunk==0)
	{
		if(atTheRate==1 && dot==1)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	if(goForApproval==0 || haveJunk==1)	
	{
		return 0;
	}

}


//------------------------------CHECKING FOR INVALID USER-ID.




