// Form Validation Script

function checkWholeForm(theForm) {
    var why = "";
	why += checkName(theForm.name.value);
	why += checkEmail(theForm.email.value);
	if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// Name textbox
function checkName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Your Name has not been filled in.\n"
  }
return error;	  
}

// check Email string
function checkEmail(strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an E-mail address.\n";
}

if (strng == "example@axisjet.com") {
   error = "You didn't enter an E-mail address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid E-mail address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\!\~\`\#\$\%\^\*\{\}\|\'\?\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The E-mail address contains illegal characters.\n";
       }
    }
return error;    
}

/////////////////////////////////////////////////////////
//        Function to clear form input value           //
/////////////////////////////////////////////////////////
function clear_form_value(clear) {
  if (clear.defaultValue==clear.value) clear.value = ""
}
function add_form_value(add)
{
   if (add.value=="") add.value = add.defaultValue
}
