<!-- This function creates a popup text box on the screen when the user
<!-- does not fill in a required value

function validate_form ( field, msg )
{
	var message;
        message = msg;
        minlength = 1; //used to identify length of string
        //this pattern returns an error message if there are any numbers in the string
        pattern = /[0-9]/;
        
  with (field)
  {
// check for empty field
    if (value==null || value=="") 
    {
	 alert(message);
	  return false;
    }
//check for blank space or empty string
    if (value.length>0)
    {
      for(var i=0;i<value.length;i++)
      {
         if (value.charAt(i)==" ")
         { 
            alert(message)
            return false;
         }
         //checks for numbers in a required string only field
       
         if (pattern.test(value))
         {
	       	  message = msg + ' this field cannot have numbers.'
	           alert(message)
	           return false;
	 }

      }	
    }
//check for a string shorter than 2
    if (i<=minlength)
      {
         alert(message)
         return false;
      }
  
   } //end with(field)
}//function validate_form


function validate_phone ( field, msg, min, max )
{
	var message;
	message = msg;
	var maxlength;
	maxlength = max;
	var minlength;
	minlength = min;
	with (field)
	{
		
		if (value.length>maxlength||value.length<minlength)
		{
		//style.background = 'Yellow';
		alert(message); 
		return false;
		
		}

	else
	{
	<!-- no need to check background color
	//style.background = 'White';
	return true;
	}
}
}
function validate_dropdown(fieldId, blank)
{
	var selection = document.getElementById("fieldId");
	var dflt = blank
with (fieldId)
{
if (options[fieldId.selectedIndex].text==dflt)
{
fieldId.style.background = 'Yellow';
return false;
}
else 
{
fieldId.style.background = 'White';
return true;
}
}
}
function validate_email(field, message)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (value==null||value=="")
  {
	  field.style.background = 'Yellow';
	  field.value = message ;
	  return false;
  }
if (value==message)
  {
 	  field.style.background = 'Yellow';
	  field.value = message ;
	  return false;
  }
if (apos<1||dotpos-apos<2) 
  {
	  style.background = 'Yellow';
	  field.value = message;
	  return false;
  }
else 
{
	style.background = 'White';
	return true;
}
}
}//validate_form

//this function validates a date field to contain mm/dd/yyyy or mm/dd/yy

function validate_date ( field, msg )
{
	var message;
	message = msg;
	minlength = 8;
	maxlength = 10;
	pattern = /[0-9 /]/;
	
   with (field)
   {
   	//check for empty field
   	if (value==null || value=="") 
	{
	    alert(message);
	    return false;
        }
   //check for blank space or empty string
   //this will allow 1/1/2001 BUT also allows 01/01/01
       if (value.length>=minlength & value.length<=maxlength)
       {
         for(var i=0;i<value.length;i++)
         {
            if (value.charAt(i)==" ")
            { 
               alert(message)
               return false;
            }
            //checks for numbers in a required string only field
          
            if (!pattern.test(value.charAt(i)))
            {
   	       	  message = msg + ' this field must have numbers and slashes.'
   	           alert(message)
   	           return false;
   	    }
         }//end for	
       }//end if
       else
       {
    	  message = msg + ' this field should be in the format dd/mm/yyyy.' 
          alert(message)   	   
              
       }//end else (length of field to short or to long
    
   }//end with

}//end validate_date

