// JavaScript Document

function validate(form)
	{
	var text = "";
		if (form.FirstName.value.length < 2)
			text += "\nFirst Name is required";
		if (form.LastName.value.length < 3)
			text += "\nLast Name  number is required";
		if (form.Company.value.length < 3)
			text += "\nCompany Name is required";
		if (form.Email.value.length < 3)
			text += "\nEmail address is required";
		if (form.Email.value.length > 5){	
			if (echeck(form.Email.value) != true) {text += "\nEmail Address is invalid";}
			}
		if (text != ""){
			sendmsg(text);
			return false;
		}
		else {
			return validdate(document.form)
		}
}
	
	function sendmsg(text)
{
		text = "Please correct the following:\n" + text
		alert(text);		
		}
		
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }	
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
	}

<!-- Checks for special characters -->
function filterNum(str) {
          re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
          // remove special characters like "$" and "," etc...
          return str.replace(re, "");
}

<!-- Checks for special characters, but allows an email address "@ and ." -->
function filterEmail(str) {
          re = /\$|,|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|/g;
          // remove special characters like "$" and "," etc...
          return str.replace(re, "");
}