function validate_form ( )
//tells the browser that we are writing some JavaScript
{
    valid = true;
//We use this valid variable to keep track of whether our form has been filled out correctly. If one of our checks fails, we'll set valid to false so that the form won't be sent.

    if ( document.quote.CompanyName.value == "" )
    {
        alert ( "Please fill in the 'Company Name' box." );
        return false;
    } 
//If the field is empty, the user is warned with an alert box, and the variable valid is set to false.


    if ( document.quote.ContactName.value == "" )
    {
        alert ( "Please fill in the 'Contact Name' box." );
        return false;
    } 


    if ( document.quote.Address.value == "" )
    {
        alert ( "Please fill in the 'Address' box." );
        return false;
    } 
	

    if ( document.quote.CityState.value == "" )
    {
        alert ( "Please fill in the 'City and State' box." );
        return false;
    } 
	
 if ( document.quote.zipcode.value == "" )
    {
        alert ( "Please fill in the 'Zip Code' box." );
        return false;
    } 
    if (document.quote.Email.value == "" || document.quote.Email.value.indexOf("@") == -1 || document.quote.Email.value.indexOf(".") == -1 )
//here the user is warned with an alert box if the field doesn't contain an index of @ or a dot(.)
    {
        alert ( "Please fill in the 'Email Address' box with a valid email address." );
        return false;
    } 
	

    if (isNaN(document.quote.PhoneNumber.value) || document.quote.PhoneNumber.value.length < 10)
//here the user is warned with an alert box if the field doesn't contain 10 numbers with no dashes or spaces
    {
        alert ( "Please fill in the 'Phone Number' box with area code and no dashes or spaces." );
        return false;
    } 
	
	
	
	
    return valid;
}
//Finally, we return the value of our valid variable to the onSubmit attribute. If the value is true then the form will be sent to the server; if it's false then the form will not be sent:

//http://www.elated.com/tutorials/programming/javascript/form_validation/