// JavaScript Document

function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
} // function validate email ends here
	 
function validate_name(name,alrttxt){
	var regexLetter = /[a-zA-z]/;
	if(!regexLetter.test(name.value)){
	alert(alrttxt);
	return false;
	}
	else{
		return true;
	}
}
function check_number(number,alrttxt){
	var regexNumb = /[0-9]/;
	if(!regexNumb.test(number.value)){
	alert(alrttxt);
	return false;
	}
	else{
		return true;
	}
}
function check_empty(mess,alrtxt){
	  if (mess.value == "") {
     alert(alrtxt);
     return false;
  }
  else
     return true;
}

function validate_form(thisform)
{
with (thisform)
  {
	if(validate_name(name,"Name can contain alphabets only!")==false)
	{name.focus();return false;}
	
    if(validate_email(email,"Not a valid e-mail address!")==false)
    {email.focus();return false;}
	
	if(check_number(phone,"Phone no. must be a valid number!")==false)
	{phone.focus();return false;}
	
	if(check_number(budget,"Buget must be a valid no.")==false)
	{budget.focus();return false;}
	
	if(check_empty(message,"Empty message can't be accepted!")==false)
	{message.focus();return false;}
  }
}
