
var emailfilter = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
function checkmail(e) {
	var returnval = emailfilter.test(e.value);
	if (returnval == false) {
		alert("Please enter a valid email address.");
		e.select();
	}
	return returnval;
}


function validateContactNbr( e ) {
	if(e.value) {
		if(e.value.length < 10 ||
		   e.value.length > 14) {
		   alert("Please enter at least 10 digits for phone/contact fields");
		}
	}
}


function validZip( e ) {
	if(e.value) {
		if(e.value.length < 5 )
		{
			alert("Please enter a valid zip code");
		}
	}
}



function checkdate(input)
{
	
	if(input.value == '' || input.value == null)
	{
		return false;
	}
		
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/; //Basic check for format validity
	var returnval=false;
	if (input.value != '' && 
		input.value != null &&
		!validformat.test(input.value))
	{
		alert("Invalid Date Format. Please correct and use format (mm/dd/yyyy).");
		input.value = "";
		
	}
	else
	{ //Detailed check for valid date ranges
		var monthfield=input.value.split("/")[0]
		var dayfield=input.value.split("/")[1]
		var yearfield=input.value.split("/")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
		{
			alert("Invalid Day, Month, or Year range detected. Please correct and use format (mm/dd/yyyy).");
			input.value = "";
		}
		else
		{
			returnval=true;
		}
	}
	if (returnval==false)
	{
		 //input.select();
	}
	return returnval;
}

<!-- Begin
function validationSSN(ssnVal) {
	var ssn = ssnVal.value;
	var matchArr = ssn.match(/^(\d{3})-?\d{2}-?\d{4}$/);
	var numDashes = ssn.split('-').length - 1;
	if (matchArr == null || numDashes == 1) {
		alert('Invalid SSN. Must be 9 digits or in the form NNN-NN-NNNN.');
		msg = "does not appear to be valid";
	}
	else if (parseInt(matchArr[1],10)==0) {
		alert("Invalid SSN: SSN's can't start with 000.");
		msg = "does not appear to be valid";
	}
	else {
		msg = "appears to be valid";
		alert(ssn + "\r\n\r\n" + msg + " Social Security Number.");
	   }
}
//  End -->

function validateNumberOnly(theForm)
{
   
   if (!IsNumeric(theForm.value)) 
   { 
      alert('Please enter only numbers in the field') 
      theForm.focus(); 
      return false; 
   } 
   return true;
} 


/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/

function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}



