<!--
function date_validate(hldForm)
{
   var chk    = 0;
   var maxDay = 0;
   var dd = hldForm.dayofbirth.value; // day
   var mm = hldForm.monthofbirth.value; // month
   var yyyy = hldForm.yearofbirth.value; // year

// calling function to get maximum day for this month
maxDay = max_day(mm, yyyy);

if((dd <= 0) || (dd > maxDay))
{ chk = 1;}
else if((mm <= 0) || (mm > 12))
{ chk = 1;}
else if((yyyy <= 0))
{ chk = 1;}

if(chk == 1)
{
	alert('The date you entered appears invalid! Please check your date of birth!');
	return false;
}
else
	return true;
}

// function for calculating maximum day
function max_day(mn, yr)
{
   var mDay;
if((mn == 4) || (mn == 6) || (mn == 9) || (mn == 11))
{
mDay = 30;
}
else if(mn == 2)
{
//calling leap year function
mDay = isLeapYear(yr) ? 29 : 28;
}
else
{
mDay = 31;
}
return mDay;
}

// function to check leap year
function isLeapYear(yr)
{
if (yr % 2 == 0)
   return true;
   return false;
}

// function to restrict any non-numeric key pressing
function nn_Key()
{
if ((event.keyCode<48) || (event.keyCode>57))
event.keyCode = 0;
}

function postit(thisForm){ //check postcode format is valid
 test = thisForm.postcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 thisForm.postcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  thisForm.postcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   thisForm.postcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position. Please ensure you have used a 0 instead of a O.  For example W14 OBY should be W14 0BY");
   thisForm.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   thisForm.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   thisForm.postcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position. Please ensure there is a space in your post code. For example PL15RE should be PL1 5RE");
   thisForm.postcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   thisForm.postcode.focus();
   return false;
  }

return true;
}


function validatePwd()
{
	var invalid = " "; // Invalid character is a space
	var minLength = 6; // Minimum length
	var pw1 = document.myForm.password.value;

	// check for minimum length
	if (document.myForm.password.value.length < minLength)
		{
		alert('Your password must be at least ' + minLength + ' characters long. Please try again.');
		document.myForm.password.value = '';
		return false;
		}

	// check for spaces
	if (document.myForm.password.value.indexOf(invalid) > -1)
		{
		alert('Sorry! Spaces are not allowed in your password. Please try again.');
		document.myForm.password.value = '';
		return false;
		}
		else
		{
		// ok
		return true;
		}
}



<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Changes:
/* 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */
// -->

<!-- Begin
function regEmailCheck(emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

//alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
//alert("Ths email address contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
//alert("Ths email address contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

//alert("The email address doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
//alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
//alert("The email address does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
//alert("The email address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
//alert("This email address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}



function goNew()
 {
	var anyerrors = 0;
	var tohome = 0;
	var error_message = 'Please enter your:\n';

	if(document.getElementById('firstname').value == "" || document.getElementById('firstname').value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- First name\n');
		}

	if(document.getElementById('lastname').value == "" || document.getElementById('lastname').value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Last name\n');
		}
	
	if(document.myForm.screenname.value == "" || document.myForm.screenname.value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Screen name\n');
		}
		else
		{
			if (document.myForm.screenname_ok.value != 1){
				anyerrors = 1;
				error_message = (error_message + '- Incorrect screen name\n');
			}
		}
	
	var lcaseemail = document.getElementById('player_emailaddress').value.toLowerCase();
	
	if(document.getElementById('player_emailaddress').value == "" || document.getElementById('player_emailaddress').value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Email Address\n');
		}
	
	// check the emailConfirmation value
	
	var emailConfirm = document.getElementById('player_emailaddress_check').value.toLowerCase();
	// run check to compare the email address values
	
	
	if(lcaseemail == emailConfirm && lcaseemail != ''){
	// address is the same
	// check email formating
		if (regEmailCheck(document.getElementById('player_emailaddress').value)){
			if (document.getElementById('player_emailaddress_ok').value == 0){
				anyerrors = 1;
				tohome = 1;
				error_message = ('You have already registered with Loopylove! Click OK to login\n');
			}
			if (document.getElementById('player_emailaddress_ok').value == 2){
				anyerrors = 1;
				error_message = ('Your profile has been deleted from Loopylove. You may choose to undelete yourself if you wish. Log in as normal below to undelete yourself.\n');
			}
			if (document.getElementById('player_emailaddress_ok').value == 3){
				anyerrors = 1;
				error_message = ('This account has been deleted. You cannot log in to Loopylove.\n');
			}
		} 
		else {
	 		anyerrors = 1;
			error_message = (error_message + '- A incorrectly formatted email address\n');
		}
		
	} 
	else {
		anyerrors = 1;
		error_message = (error_message + '- Email address confirmation\n');
	}
	

	if(document.myForm.password.value == "" || document.myForm.password.value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Password\n');
		}
	

	
	else
		{
		if (validatePwd())
			{
			//anyerrors = 0;
			}
		else
			{
			anyerrors = 1;
			}
		}	
	
	if(document.myForm.address1.value == "" || document.myForm.address1.value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Address (first line only)\n');
		}	
	
	var selectedcountry = document.myForm.country.options[document.myForm.country.selectedIndex].value
	if(document.myForm.postcode.value == "" || document.myForm.postcode.value == null)
		{
		anyerrors = 1;
		error_message = (error_message + '- Postcode\n');
		}
	else
		{
		if (selectedcountry == 'GB')
		{
			if (postit(document.myForm) == false)
			{
			anyerrors = 1;
			error_message = (error_message + '- Postcode\n');
			}
		}
		}	
	
	// new checking for check box
/*	var c_value = "";
	for (var i=0; i < document.myForm.psex.length; i++)
	   {
	   if (document.myForm.psex[i].checked)
	      {
	     	
	      c_value = c_value + document.myForm.psex[i].value + "\n";
	      }
	   }
*/	
	//
	if (document.myForm.psex.value == 'N'){
		anyerrors = 1;
		error_message = (error_message + '- Your gender\n');
	}
	var sex2 = document.myForm.targetsex
	var sex2count = sex2.options.selectedIndex

	if (sex2count == 0)
		{
		anyerrors = 1;
		error_message = (error_message + '- Target gender\n');
		}	
	
	
	var day_ofbirth = document.getElementById('dayofbirth').options[document.getElementById('dayofbirth').selectedIndex].value
	var month_ofbirth = document.getElementById('monthofbirth').options[document.getElementById('monthofbirth').selectedIndex].value
	var year_ofbirth = document.getElementById('yearofbirth').options[document.getElementById('yearofbirth').selectedIndex].value
	
	
	if (day_ofbirth == 0 || month_ofbirth == 0 || year_ofbirth == 0)
		{
		anyerrors = 1;
		error_message = (error_message + '- Date of birth\n');
		}
	else
		{
		if (date_validate(document.getElementById('myForm')) == true)
			{
			//anyerrors = 0;
			}
		else
			{
			anyerrors = 1;
			}
		}
			
		if (document.myForm.tagline.value.length < 10)
				{
				anyerrors = 1;
				error_message = (error_message + '- Tagline must be at least 10 characters\n');
				}
				
		// description
		if (document.myForm.description.value.length < 10)
				{
				anyerrors = 1;
				error_message = (error_message + '- Description must be at least 10 characters\n');
				}
		



//		<!--- Nov 29, 2004 RE Added T&C check --->
		var boolacceptedtermsandconditions = document.myForm.tandcs
		if(document.myForm.tandcs.checked != 1)
			{
			error_message = (error_message + '- Acceptance of our Terms and Conditions');
			anyerrors = 1;
			}

	if (anyerrors == 0)
	{
		document.myForm.submit();
		return true;
	}
	else
	{
		alert(error_message);
		if (tohome == 1)
		{
			 window.location = '/home.cfm';
		}
		return false;
	}
}


//--> 