function clearInstructions(field) 
{
	if (field.defaultValue==field.value)
	field.value = ""
} 

function checkWholeForm(theForm) {
    var why = "";
    why += nameEmpty(theForm.username.value);
    why += checkEmail(theForm.email.value);
    why += commentsEmpty(theForm.comments.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,4}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

// not empty string.

function nameEmpty(strng) {
var error = "";
var instr = strng.substring(0,6);
if (instr == 'Pleas') 
{ // clear field
	strng = '';
}
  if (strng.length == 0) {
     error = "Please enter your name.\n"
  }
return error;	  
}

function commentsEmpty(strng) {
var error = "";
var instr = strng.substring(0,6);
if (instr == 'Pleas') 
{ // clear field
	strng = '';
}
  if (strng.length == 0) {
     error = "Please enter your comments.\n"
  }
return error;	  
}

//Dropdown selected

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the drop-down list.\n";
    }    
return error;
}

