  function validEmail(fld)
{
	// return error message if email is invalid
	var str = fld.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re))
		return ('Enter a valid e-mail address\n');
              
	if ( (str.indexOf('cc:') < 0) && (str.indexOf('bcc:') < 0) &&
		(str.indexOf('Content-Type:') < 0) && (str.indexOf('MIME-Version:') < 0) &&
		    (str.indexOf('Content-Transfer-Encoding:') < 0) )
		return '';
	
	// warn of third party email
		return (' fix invalid characters in email address.\n');
		
}

function validateForm()
{
  // Do validation 
  var msg = '';
  
		if (!document.qdbform._fid_7.value.length)
			msg += 'Enter your firstname.\n';
		if (!document.qdbform._fid_8.value.length)
			msg += 'Enter your lastname.\n';
        	
		if (!document.qdbform._fid_18.value.length)
			msg += 'Enter your email address.\n';
		else
		{
  			valid_email = validEmail(document.qdbform._fid_18, 'E-Mail Address');
		    if (valid_email != '')
			   msg += valid_email;		
		}	

		if (!document.qdbform._fid_17.value.length)
			msg += 'Enter your daytime phone number.\n';

	
  var x=document.getElementById("besttime");
  if (x.selectedIndex == 0)
			msg += 'Select the best time to call.\n';

  x=document.getElementById("military");
  if (x.selectedIndex == 0)
			msg += 'Let us know if you are associated with the military.\n';

  x=document.getElementById("degree");
  if (x.selectedIndex == 0)
			msg += 'Let us know your area of interest.\n';
	
 		if (msg != '')
		{
			var err_msg = 'Please include the following information.\n';
			err_msg += msg;
			alert(err_msg);
			return false;
		}
	

//	 document.qdbform.action = "https://www.quickbase.com/db/bd569cqiq?act=API_AddRecord&apptoken=cwfcy7gdzqrsyncqbi2bn4u4kr";
  document.forms["qdbform"].submit();
  
  return true;

}


