// JavaScript Document
function validate(protect)
{

if(protect.fname.value=="")
 {alert("Field Empty. Please Enter Your First Name")
 protect.fname.focus();
 return false;
}
if(protect.fname.value.length<3)
 {alert("Please Enter Your First Name minimum three characters")
 protect.fname.focus();
 return false;
}
if(protect.lname.value=="")
 {alert("Field Empty. Please Enter Your Last Name")
 protect.lname.focus();
 return false;
}
if(protect.lname.value.length<3)
 {alert("Please Enter Your Last Name minimum three characters")
 protect.lname.focus();
 return false;
}
if(protect.HPHONE.value=="")
 {alert("Field Empty. Please Enter Home Phone")
 protect.HPHONE.focus();
 return false;
 }
 if(isNaN(protect.HPHONE.value))
 {alert("Please Enter Home Phone Number (only Numbers)")
 protect.HPHONE.focus();
 return false;
 }
if(protect.HPHONE.value.length<10)
{alert("Please Enter Valid Home Phone Number minimum 10 digit")
 protect.HPHONE.focus();
 return false;
	}
if(isNaN(protect.DPHONE.value))
 {alert("Please Enter Please Enter Other Phone Number (only Numbers)")
 protect.DPHONE.focus();
 return false;
 }
	
if(protect.DPHONE.value.length<10)
{alert("Please Enter Valid Other Phone Number minimum 10 digit")
 protect.DPHONE.focus();
 return false;
	}
 if(protect.address.value=="")
 {alert("Field Empty. Please Enter Address")
 protect.address.focus();
 return false;
 }
  if(protect.address.value.length<6)
 {alert("Field Empty. Please Enter Address minimum 6 characters")
 protect.address.focus();
 return false;
 }
  if(protect.city.value=="")
 {alert("Field Empty. Please Enter City Name")
 protect.city.focus();
 return false;
 }
 if(protect.city.value.length<4)
 {alert("Please Enter City Name minimum 4 characters")
 protect.city.focus();
 return false;
 }
 if(protect.state.value=="")
 {alert("Field Empty. Please Select State")
 protect.state.focus();
 return false;
 }
 
if(protect.zip.value=="")
 {alert("Field Empty. Please Enter Your Zipcode")
 protect.zip.focus();
 return false;
 }
 if(isNaN(protect.zip.value))
 {alert("Please Enter Valid Zipcode")
 protect.zip.focus();
 return false;
 }

 if(protect.zip.value.length<5)
 {alert("Please Enter Your Zipcode 5 Characters")
 protect.zip.focus();
 return false;
 }
if(protect.email.value=="")
{alert("Field Empty. Please Enter Your Mail ID")
protect.email.focus();
return false;
}
if(!validmail(protect.email))
{
	
}
if(protect.email.value!=protect.confirm_email.value)
{
alert("Email and Re Enter Email fields are not Same")
 protect.confirm_email.focus();
return false;
}
}	



	
function validmail(obj)
	{								 <!--  checking valid email address-->		
									
var EmailOk  = true
var Temp     = obj
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

if(obj.value !=""){
if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      EmailOk = false
      alert("Please enter a valid e-mail address!");
      Temp.value="";
      Temp.focus();
      return EmailOk;
   }
	}

}

function validnum(obj)
{//alert(event.keyCode)
  	if (navigator.appName=="Microsoft Internet Explorer")
	{
	//alert(event.keyCode)
		if((event.keyCode <48 || event.keyCode >57) || window.event.shiftKey )
		if (event.keyCode!=45)
		event.returnValue =false;
	}
	if (navigator.appName=="Netscape")
	{
		var num="0123456789";
	
		//If any value is not a number set return value to false
		for(var intloop=0;intloop<obj.value.length;intloop++)
		{
			//alert(num.indexOf(document.formDetails.txtAge.value.charAt(intloop)));
			if (-1==num.indexOf(obj.value.charAt(intloop)))
			{
				//document.formDetails.txtAge.value="";
				alert("Please enter numbers only")
				obj.value="";
				obj.focus()
				
			}
		}
			}
}

