// JavaScript Document
	
	function validateFields()
	{
	
	
	
	  //document.frm.state.disabled=false;
	
	if (trim(document.frm.firstname.value)=="")
			{
			alert("FirstName is Required");
			document.frm.firstname.focus();
			return false;	
			}
		
	if (trim(document.frm.lastname.value) == "")
			{
			alert("LastName is Required");
			document.frm.lastname.focus();
			return false;	
			}
			 if (trim(document.frm.email.value) == "")
			{
				alert("Email is Required");
				document.frm.email.focus();
				return false;
			}
		else if (echeck(document.frm.email.value) == false){
				document.frm.email.value="";
				document.frm.email.focus();
				return false;
			}
		if (trim(document.frm.street_address.value) == "")
			{
			alert(" Street Address is Required");
			document.frm.street_address.focus();
			return false;	
			}	
		
		 if (document.frm.postcode.value == "")
			{
			alert("Post Code is Required");
			document.frm.postcode.focus();
			return false;	
			}
	else if(isNaN(document.frm.postcode.value))
		{
		alert("Invalid Postcode No.");
			document.frm.postcode.focus();
			return false;
		}	
	  if (document.frm.city.value == "")
			{
			alert("City is Required");
			document.frm.city.focus();
			return false;	
			}
	if (document.frm.state.value == "")
			{
			alert("State is Required");
			document.frm.state.focus();
			return false;	
			}
     if (trim(document.frm.country.value)=="")
			{
			alert("Country is Required");
			document.frm.country.focus();
			return false;	
			}			
	if (trim(document.frm.telephone.value)=="")
			{
			alert("Telephone Number is Required");
			document.frm.telephone.focus();
			return false;	
			}
		else if(isNaN(document.frm.telephone.value))
		{
		alert("Invalid telephone No.");
			document.frm.telephone.focus();
			return false;
		}	
			
	if (trim(document.frm.ship_add.value) == "")
			{
			alert("Shipping Address is Required");
			document.frm.ship_add.focus();
			return false;	
			}
				
		if (trim(document.frm.upassword.value)== "")
		{
			alert("Password missing.");
			document.frm.upassword.focus();
			return false;	
		}
		if (document.frm.upassword.value != document.frm.repass.value)
		{
			alert("Password doesn't match. Please enter again.!");
			document.frm.upassword.focus();
			return false;	
		}	
		if ((document.frm.upassword.value.length<=5) || (document.frm.upassword.value.length>=19))
		{
			alert("Password should be greater than 6 and less than 20 digit!");
			return false;	
		}
		
}
  function trim(str)
  {
  	return str.replace(/^\s+|\s+$/g,'');
  }
  function echeck(str) {

		//alert(str);
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

 		 return true					
	}

//fn to check Date in mm/dd/yyyy

