function trim(str)
    {
        return str.replace(/^\s+|\s+$/g,'');
    }
function validationreg()
{
	//name
	if(trim(document.getElementById("txtname").value)=="")
	{
		alert("Enter Name");
		document.getElementById("txtname").focus();
		return false;
	}
	// street address
	if(trim(document.getElementById("txtstreet1").value)=="")
	{
		alert("Enter Street Address");
		document.getElementById("txtstreet1").focus();
		return false;
	}
	//city
	if(trim(document.getElementById("txtcity").value)=="")
	{
		alert("Enter City");
		document.getElementById("txtcity").focus();
		return false;
	}
		//state
	if(document.getElementById("ddlstate").value==0)
	{
		alert("Select State");
		document.getElementById("ddlstate").focus();
		return false;
	}
		// zip code
	if(trim(document.getElementById("txtzip").value)=="")
        {
            alert("Enter Zip Code!");
            document.getElementById("txtzip").focus();
            return false;
        }
        if(isNaN(document.getElementById("txtzip").value))
        {
            alert("Enter a valid Zip Code!");
            document.getElementById("txtzip").focus();
            return false;
        }
		 if(document.getElementById("txtzip").value.length!=5)
        {
				alert("Enter a valid Zip Code!");
				document.getElementById("txtzip").focus();
				return false;
        }
			//phone
	if(trim(document.getElementById("txtphone").value)=="")
	{
		alert("Enter Phone");
		document.getElementById("txtphone").focus();
		return false;
	}
	var data=document.getElementById("txtphone").value;
    var iChars = "!@#$%^&*=[]\\\;,'./{}|\":<>?~_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
    for (var i = 0; i < data.length; i++) 
    {
  	     if (iChars.indexOf(data.charAt(i)) != -1) 
  	     {
  	         alert ("Enter a valid Phone Number.");
  	         document.getElementById("txtphone").focus();
  	         return false;
		 }
	}
	//email
	if(trim(document.getElementById("username").value)=="")
	{
		alert("Enter E-mail");
		document.getElementById("username").focus();
		return false;
	}
	var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    var emailid=document.getElementById("username").value;
    var matchArray = emailid.match(emailPat);
    if (matchArray == null)
    {
        alert("Enter a valid E-mail Id.");
        document.getElementById("username").focus();
        return false;
    }
	//password
	if(trim(document.getElementById("txtpassword").value)=="")
	{
		alert("Enter Password");
		document.getElementById("txtpassword").focus();
		return false;
	}
	//re-enter password
	if(trim(document.getElementById("txtrepassword").value)=="")
	{
		alert("Re-enter Password");
		document.getElementById("txtrepassword").focus();
		return false;
	}
		var repswd=document.getElementById("txtrepassword").value;
		var pswd=document.getElementById("txtpassword").value;
		if(repswd!=pswd)
		{
			alert("The Passwords Do Not Match");
			return false;
	}
	//fan
	if(document.getElementById("fan1").checked==false)
	{
		if(document.getElementById("fan2").checked==false)
		{
			alert("Are you a romance novel fan?");
			return false;
		}
	}
	//book
	if(document.getElementById("book1").checked==false)
	{
		if(document.getElementById("book2").checked==false)
		{
			alert("Have you ever read a Genesis Press Indigo or Indogo Love Spectrum Book?");
			return false;
		}
	}
	//terms n conditions
	if(document.getElementById("chkterms").checked==false)
	{
		alert("You have to accept the terms and conditions.");
		return false;
	}
	
}

