//EmailPlusCheck.js

/*
This file checks if email address is in correct format
Add onChange="return checkEmail(this, true);" in appropriate input box

use true if the input box can be left empty, use false if it is required.
*/
 
//---------------- VARIABLE DECLARATIONS ----------------


var emailregex = /^[\w\_\-\.]+@[\w\_\-\.]+\.\w+$/;
  
function checkEmail(theField, emptyOK)
{
	if(theField.value.length == 0 && (emptyOK))
	{
		return true;
	}
	else
	{
		if(!theField.value.match(emailregex))
			{
			alert("The email address  " + theField.value + "  is not in a correct format.\n Please try again");
			theField.focus();
			theField.select();
			return false;
		}
	}

}