// function for validating form fields and submitting
function validate()
{
/*		function to validate the email */
		if(document.frmres.txtuname.value.length==0){
			alert("User name can't be Empty");
			document.frmres.txtuname.value="";
			document.frmres.txtuname.focus();
			return false;
		}
		if (!ValidateEmail(document.frmres.txtuname.value)){
			alert("Please enter a valid email address.");
			document.frmres.txtuname.focus();
			return (false);
		}

		if(document.frmres.txtpwd.value.length==0){
			alert("Password can't be Empty");
			document.frmres.txtpwd.value="";
			document.frmres.txtpwd.focus();
			return false;
		}
		if(document.frmres.txtcpwd.value.length==0){
			alert("Confirm Password can't be Empty");
			document.frmres.txtcpwd.value="";
			document.frmres.txtcpwd.focus();
			return false;
		}
		if(document.frmres.txtpwd.value!=document.frmres.txtcpwd.value){
			alert("Password not Match")
			document.frmres.txtcpwd.value=""
			document.frmres.txtcpwd.focus();
			return false;
		}
		if(document.frmres.txtfname.value.length==0){
			alert("Full Name can't be Empty");
			document.frmres.txtfname.value="";
			document.frmres.txtfname.focus();
			return false;
		}

					// Check for the year should not greater than the current year 		
		 if(document.frmres.exp_y.value=="Year"){
			alert(" Select the Year ") 
			document.frmres.exp_y.focus();
			return false;
		  }
		  
		  if(document.frmres.exp_y.value >= new Date().getFullYear()) {
		  		alert(" Birth Date Should not Greater than the Current Date") 
				document.frmres.exp_y.focus();
				return false;
		  }
					// Check for the current year and month should greater than the current month
		  if(document.frmres.exp_m.value=="Month"){
			alert(" Select the Month ") 
			document.frmres.exp_m.focus();
			return false;
		  }
		  
		  if(document.frmres.exp_d.value=="Day"){
			alert(" Select the Day ") 
			document.frmres.exp_d.focus();
			return false;
		  }

		if(document.frmres.txtfname.value.length>50)
			{
			alert("The number of characters permitted is only 50");
			document.frmres.txtfname.focus();
			return false;
			}
		if(document.frmres.txtreligion.value.length>50)
			{
			alert("The number of characters permitted is only 50");
			document.frmres.txtreligion.focus();
			return false;
			}
		if(document.frmres.txtreligion.value.length>50)
			{
			alert("The number of characters permitted is only 50");
			document.frmres.txtreligion.focus();
			return false;
			}
		if(document.frmres.txtcommunity.value.length>50)
			{
			alert("The number of characters permitted is only 50");
			document.frmres.txtcommunity.focus();
			return false;
			}
		if(document.frmres.txtpno.value.length>50)
			{
			alert("The number of characters permitted is only 50");
			document.frmres.txtpno.focus();
			return false;
			}

			if(document.frmres.txtcaddr1.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcaddr1.focus();
				return false;
				}
			if(document.frmres.txtcaddr2.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcaddr2.focus();
				return false;
				}
			if(document.frmres.txtccity.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtccity.focus();
				return false;
				}
			if(document.frmres.txtcstate.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcstate.focus();
				return false;
				}
			if(document.frmres.txtccountry.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtccountry.focus();
				return false;
				}
			if(document.frmres.txtcpincode.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcpincode.focus();
				return false;
				}
			if(document.frmres.txtcrphone.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcrphone.focus();
				return false;
				}
			if(document.frmres.txtcophone.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtcophone.focus();
				return false;
				}
			if(document.frmres.txtpaddr1.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpaddr1.focus();
				return false;
				}
			if(document.frmres.txtpaddr2.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpaddr2.focus();
				return false;
				}
			if(document.frmres.txtpcity.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpcity.focus();
				return false;
				}
			if(document.frmres.txtpstate.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpstate.focus();
				return false;
				}
			if(document.frmres.txtpcountry.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpcountry.focus();
				return false;
				}
			if(document.frmres.txtppincode.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtppincode.focus();
				return false;
				}
			if(document.frmres.txtprphone.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtprphone.focus();
				return false;
				}
			if(document.frmres.txtpophone.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtpophone.focus();
				return false;
				}
			if(document.frmres.txtmobile.value.length>50){
				alert("The number of characters permitted is only 50");
				document.frmres.txtmobile.focus();
				return false;
				}
				
				if(document.frmres.txtemail.value.length>0){
					if (!ValidateEmail(document.frmres.txtemail.value)){
						alert("Please enter a valid email address.");
						document.frmres.txtemail.focus();
						return false;
					}
				}	
	    }
	 	function ValidateEmail(mailid){
		   // validates the supplied email 
			if (mailid == ""){
				  return (false);
			}
			if ((mailid.indexOf("@") < 1) || 
				(mailid.indexOf("@") == mailid.length-1) || 
				(mailid.indexOf(".") < 1) || 
				(mailid.indexOf(".") == mailid.length-1)){
				  return (false);
				}
			else	
				return (true);
		}
 /*
 	function ValidateEmail(mailid){
		   // validates the supplied email 
			if (mailid == ""){
				  return (false);
			}
			if ((mailid.indexOf("@") < 1) || 
				(mailid.indexOf("@") == document.frmres.txtuname.value.length-1) || 
				(mailid.indexOf(".") < 1) || 
				(mailid.indexOf(".") == document.frmres.txtuname.value.length-1)){
				  return (false);
				}
			else	
				return (true);
		}
	*/
