function validateFields()
{var test
	var Doc = document.frmRegistration
	if(TrimString(Doc.name.value) == "" )
		{
		 	alert("Name is missing, please enter your name");
			Doc.name.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.address1.value) == "" )
		{
		 	alert("Address is missing, please enter your address");
			Doc.address1.focus()
			return false
			test="failed";
		}
		else
		{
		if(TrimString(Doc.town_city.value) == "" )
		{
		 	alert("Please enter your town or city name");
			Doc.town_city.focus()
			return false
			test="failed";
		}
		else
		{
		if(TrimString(Doc.state_province_county.value) == "" )
		{
		 	alert("Please enter your state or province name");
			Doc.state_province_county.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.phone.value) == "" )
		{
		 	alert("Phone No. is missing, please enter your phone number");
			Doc.phone.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.email.value) == "" )
		{
		 	alert("Please enter your email address");
			Doc.email.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.user_name.value) == "" )
		{
		 	alert("Please enter user name");
			Doc.user_name.focus()
			return false
			test="failed";
		}
	else
		{Doc.user_name.value=TrimString(Doc.user_name.value)
		if(eval(Doc.user_name.value.length) < 6 )
		{
		 	alert("Please enter user name minimum of 6 characters");
			Doc.user_name.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.password.value) == "" )
		{
		 	alert("Please enter password");
			Doc.password.focus()
			return false
			test="failed";
		}
	else
		{Doc.password.value=TrimString(Doc.password.value)
		if(eval(Doc.password.value.length) < 6 )
		{
		 	alert("Please enter password minimum of 6 characters");
			Doc.password.focus()
			return false
			test="failed";
		}
	else
		{
		if(TrimString(Doc.confirm_password.value) == "" )
		{
		 	alert("Please confirm your password");
			Doc.confirm_password.focus()
			return false
			test="failed";
		}
	else
		{
		if(Doc.find_source.value == "select" )
		{
		 	alert("Please tell us how did you find us?");
			Doc.find_source.focus()
			return false
			test="failed";
		}
	else
		{
		if(Doc.terms.checked == false)
		{
		 	alert("Please tick checkbox if you have read our terms & conditions");
			Doc.terms.focus()
			return false
			test="failed";
		}
	else
		{
emailStr = Doc.email.value
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Email address seems incorrect (check @ and .'s)")
	return false
	test="failed";
}
var user=matchArray[1]
var domain=matchArray[2]

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Email address seems incorrect (check @ and .'s)")
    return false
	test="failed";
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
   test="failed";
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
   test="failed";
}
}
}}}}}}}}}}}}


    if(Doc.user_name.value !="")
     {
     	var numaric = Doc.user_name.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))
		  {
		  }
		  else	
		  {
			 alert("ERROR: Only Alphabets or Numbers are allowed in user name field");
			 Doc.user_name.focus();
			 return false;
			 test="failed";
		  }
		}
	 }
	
	 	if(Doc.password.value !="")
        {
     	var numaric = Doc.password.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))
		  {
		  }
		  else	
		  {
			 alert("ERROR: Only Alphabets or Numbers are allowed in password field");
			 Doc.password.focus();
			 return false;
			 test="failed";
		  }
		}
	    }

	 
	    if(Doc.confirm_password.value != Doc.password.value )
		{
		 	alert("Password validation failed, please enter your password again");
			Doc.confirm_password.focus()
			return false
			test="failed";
		}

if(test != "failed")
   {
   		Doc.submit();
   }
}
function TrimString(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}