// JavaScript Document
function validate()
	{
		var sname=document.getElementById("name").value
		var address=document.getElementById("address").value
		var hphone=document.getElementById("hphone").value
		var cphone=document.getElementById("cphone").value
		var email=document.getElementById("email").value
		var wphone=document.getElementById("wphone").value
		if(sname.length>3  && address.length>3 && phno(hphone,cphone,wphone)==true && validate_email(email)==true)
			{
				return true
			}
		else
			{
				return false	
			}
	}
function validate1()
	{
		var sname=document.getElementById("name").value
		var hphone=document.getElementById("hphone").value
		var cphone=document.getElementById("cphone").value
		var email=document.getElementById("email").value
		var wphone=document.getElementById("wphone").value
		if(sname.length>3 && phno(hphone,cphone,wphone)==true && validate_email(email)==true)
			{
				return true
			}
		else
			{
				return false	
			}
	}
	
function phno(p1,p2,p3)
	{
		if(isNaN(p1)==false && isNaN(p2)==false && isNaN(p3)==false)
			{
				if((p1.length==0 || p1.length==10) && (p2.length==0 || p2.length==10) && (p3.length==0 || p3.length==10))
			{
		if(valphno(p1)==true || valphno(p2)==true || valphno(p3)==true)
			{
				if(valphno1(p1)==true || valphno1(p2)==true || valphno1(p3)==true)
					{
						return true;	
					}
				else
					{
						alert("Phone Number is not valid")
						return false;
					}
			}
		else
			{
				alert("Phone Number is not valid")
				return false;	
			}
			}
		else
			{
				alert("Phone Number is not valid")
				return false;	
			}	
			}
		else
			{
				alert("Phone Number is not valid")
				return false;	
			}
	}
function valphno(p)
	{
		if(p.length==0 || p.length==10)
			{
				return true;	
			}
		else
			{
				return false;	
			}
	}
function valphno1(j)
	{
		if(j.length==10)
			{
				return true;	
			}
		else
			{
				return false;	
			}
	}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function validate_email(e)
	{
		var returnval=emailfilter.test(e)
		if (returnval==false)
			{
				alert("Please enter a valid email address.")
				return false;
			}
		else
			{
				return true;	
			}
}


