
function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}


function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function validateCheckBox(chk, alertbox){

  if (chk.checked == true)
  {
	return true;
  }
  else
  {
    alert(alertbox)
   return false;
  }
}

	
function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}



function EmailFormvalidation(_thisform)
{
	with (_thisform)
	{
		if (emptyvalidation(Name,"Please fill in your name")==false) {Name.focus(); return false;};
		if (emptyvalidation(Email,"Please fill in your email")==false) {Email.focus(); return false;};	
	}
}


function validateTextArea(txt,alertbox)
{
	
	if(txt.value.length>0)
	{
		return true;
	}
	else
	{
		alert(alertbox)
   		return false;
	}
	
}



function validateDropDown(entered, alertbox)
{
	with (entered)
	{
		if (value==null || value=="")
			{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
	}
}


function alphanumeric(alphane,alertbox)
{
	var numaric = alphane.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh == 32))
		  {
		  }
		else	{
			 alert(alertbox)
			 return false;
		  }
		}
 return true;

}



function formvalidation(thisform)
{
// This function checks the entire form before it is submitted
// Note: This function needs to be customized to fit your form

	
	with (thisform)
	{
	
		if (emptyvalidation(fname,"Please fill in your first name")==false) {fname.focus(); return false;};
		if (emptyvalidation(lname,"Please fill in your last name")==false) {lname.focus(); return false;};
		
		if (emailvalidation(email,"Please enter a valid email address")==false) {email.focus(); return false;};

        if (validateDropDown(profession,"Please select a profession")==false) {profession.focus(); return false;};
		
		if (emptyvalidation(title,"Please fill in your Title or Position")==false) {title.focus(); return false;};
		if (emptyvalidation(company,"Please fill in your company")==false) {company.focus(); return false;};
	}
	
	
}

