
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);
return false
}
else {return true}
}
}



<!-- This function is called to validate the value entered into the email fieldof the table, when the function is called the field that needs to be validated and the text to display if the field is not valid is specified -->
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}
}
<!-- This function is called when the form is submitted, it goes through and calls different functions to validate different field types, when calling the function it specifies the field to be validated and the text to display if the field is not valid -->
}

function validate_phone(field,aa)
{
with (field)
{
var ph=value.search(/\d{9,12}/)
   if(ph==-1)
   {
      alert(aa);
      return false;
   }
}
}
function validateS(field,aa)
{
with (field)
{
				var selectedCombobox=(document.requestquote.service.value);
				if (selectedCombobox=="-1") {
					alert(aa);
					return false;
				}
				return true;
			}
}
function validateB(field,aa)
{
with (field)
{
				var selectedCombo=(document.requestquote.budget.value);
				if (selectedCombo=="-1") {
					alert(aa);
					return false;
				}
				return true;
			}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Please enter your name!")==false)
{name.focus();return false}

if (validate_required(company,"Please enter your Company name!")==false)
{name.focus();return false}

if (validate_email(email,"Not a valid e-mail address!")==false)
{email.focus();return false}

if (validate_phone(phone,"Not a valid Phone no!")==false)
{phone.focus();return false}

if (validateS(service,"Choose your Service!")==false)
{service.focus();return false}

if (validateB(budget,"Select your budget!")==false)
{budget.focus();return false}

if (validate_required(mssg,"Please enter your Message!")==false)
{mssg.focus();return false}

}
}

