function checkrequired() {
userName = document.CreateAcount.UserName.value;
password = document.CreateAcount.Password.value;
passwordConfirm = document.CreateAcount.PasswordConfirm.value;
firstName = document.CreateAcount.FirstName.value;
lastName = document.CreateAcount.LastName.value;
email = document.CreateAcount.Email.value;
var w = document.CreateAcount.Day.selectedIndex;
var day = document.CreateAcount.Day.options[w].text;
var wMonth = document.CreateAcount.Month.selectedIndex;
var month = document.CreateAcount.Month.options[wMonth].text;
var wYear = document.CreateAcount.Year.selectedIndex;
var year = document.CreateAcount.Year.options[wYear].text;
occupation = document.CreateAcount.Occupation.value;
aboutMe = document.CreateAcount.AboutMe.value;
whoIAmLookingFor = document.CreateAcount.WhoIAmLookingFor.value;
if(userName == ''){
alert("You must enter a User Name");
document.CreateAcount.UserName.focus();
return false;
}else if(userName.length < 6){
alert("Your User Name must be at least 6 characters long");
document.CreateAcount.UserName.focus();
return false;
}else if(!isLegalChars(userName)){
alert("Your User Name must contain only letters, numbers and underscores");
document.CreateAcount.UserName.focus();
return false;
}else if(password == ''){
alert("You must enter a Password");
document.CreateAcount.Password.focus();
return false;
}else if(password.length < 6){
alert("Your Password must be at least 6 characters long");
document.CreateAcount.Password.focus();
return false;
}else if(!isLegalChars(password)){
alert("Your Password must contain only letters, numbers and underscores");
document.CreateAcount.Password.focus();
return false;
}else if(!isValidPassword(password)){
alert("Your Password must contain a mixture of letters and numbers");
document.CreateAcount.Password.focus();
return false;
}else if(password != passwordConfirm){
alert("Your Password and Confirm Password must be the same");
document.CreateAcount.Password.focus();
return false;
}else if(firstName == ''){
alert("You must add a First Name");
document.CreateAcount.FirstName.focus();
return false;
}else if(!isLegalChars(firstName )){
alert("Your First Name must contain only letters, numbers and underscores");
document.CreateAcount.FirstName.focus();
return false;
}else if(lastName == ''){
alert("You must add a Last Name");
document.CreateAcount.LastName.focus();
return false;
}else if(!isLegalChars(lastName)){
alert("Your Last Name must contain only letters, numbers and underscores");
document.CreateAcount.LastName.focus();
return false;
}else if(!echeck(email)){
alert("Email address is invalid");
document.CreateAcount.Email.focus();
return false;
}else if(!isValidDate(day, month - 1, year)){
alert("Date of Birth is invalid");
document.CreateAcount.Day.focus();
return false;
}else if(occupation == ''){
alert("You must add an Occupation");
document.CreateAcount.Occupation.focus();
return false;
}else if(aboutMe == '' || aboutMe.length < 25){
alert("You must enter at least 25 characters for 'About Me'");
document.CreateAcount.AboutMe.focus();
return false;
}else if(whoIAmLookingFor == '' || whoIAmLookingFor.length < 25){
alert("You must enter at least 25 characters for 'Who I Am Looking For'");
document.CreateAcount.WhoIAmLookingFor.focus();
return false;
}else if(aboutMe.length > 1000){
alert("'About Me' description must not exceed 1000 characters");
document.CreateAcount.AboutMe.focus();
return false;
}else if(whoIAmLookingFor.length > 1000){
alert("'Who I Am Looking For' description must not exceed 1000 characters");
document.CreateAcount.WhoIAmLookingFor.focus();
return false;
}else if(caption.length > 200){
alert("Your caption must not exceed 200 characters");
document.CreateAcount.Caption.focus();
return false;
}else if(caption2.length > 200){
alert("Your caption must not exceed 200 characters");
document.CreateAcount.Caption2.focus();
return false;
}else if(caption3.length > 200){
alert("Your caption must not exceed 200 characters");
document.CreateAcount.Caption3.focus();
return false;
}else if(caption4.length > 200){
alert("Your caption must not exceed 200 characters");
document.CreateAcount.Caption4.focus();
return false;
}else if(caption5.length > 200){
alert("Your caption must not exceed 200 characters");
document.CreateAcount.Caption5.focus();
return false;
}
return true;
}
function isValidDate(day, month, year){
/*
Purpose: return true if the date is valid, false otherwise
Arguments: day integer representing day of month
month integer representing month of year
year integer representing year
Variables: dteDate - date object
*/
var dteDate;
//set up a Date object based on the day, month and year arguments
//javascript months start at 0 (0-11 instead of 1-12)
dteDate=new Date(year,month,day);
/*
Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
*/
return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}
function isValidPassword(password){
if (!(((password.search(/[a-z]+/) > -1)
|| (password.search(/[A-Z]+/) > -1))
&& (password.search(/[0-9]+/) > -1))) {
return false;
}
return true;
}
function isLegalChars(strng){
var illegalChars = /\W/;
/*allow only letters, numbers, and underscores*/
if (illegalChars.test(strng)) {
return false;
}
return true;
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

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					
	}


