
function checkWholeForm(theForm) {
    var why = "";
	//alert("Hi sexy");
	why += isEmpty(theForm.Name.value, 'Name');

	why += checkEmail(theForm.emailId.value, 'emailId');
	
	why += isEmpty(theForm.contactNo.value, 'contactNo');
	why += isEmpty(theForm.mobileNo.value, 'mobileNo');
		why += isEmpty(theForm.subject.value, 'subject');
	

	  
     why += isEmpty(theForm.msg.value, 'msg'); 

    
   
    if (why != "") {
       alert(why);
       return false;
    }
	else
	{
		//alert("Well done! Data is Valid");
	}
return true;
}





/**********************  VALIDATION FUNCTIONS BELOW ********************
/**********************                              *******************/


// email

function checkEmail (strng, nm) {
	document.getElementById(nm).style.background="#ffffff";
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
    document.getElementById(nm).style.background="#ffbeaa";
}
else
{

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
	    document.getElementById(nm).style.background="#ffbeaa";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
}
return error;    
}



// non-empty textbox

function isEmpty(strng, nm) {
	   document.getElementById(nm).style.background="#ffffff";
var error = "";
  if (strng.length == 0) {
     error = " ";
	 if(nm=='cp')
	 { error += 'Contact Person';
	 }
	 else
	 {
	 error += nm;
	 }
	 error += "  has not been filled in.\n";
	  document.getElementById(nm).style.background="#ffbeaa";
  }
return error;	  
}

