﻿function chkRegistrationFields()
{
/*------------------Validate First Name-----------------*/
   if (document.aspnetForm.ctl00_content1_txtfname.value=="")
   {
     alert("Enter the First Name.");
     document.aspnetForm.ctl00_content1_txtfname.focus();
     return false;
   } 
   if (document.aspnetForm.ctl00_content1_txtfname.value!="")
         {   
             var alphaExp = /^[a-zA-Z ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtfname.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for First Name.");
		        document.aspnetForm.ctl00_content1_txtfname.focus();
		        return false;
	         } 
	     }  
   
/*------------------Validate Last Name-----------------*/
   if (document.aspnetForm.ctl00_content1_txtlname.value=="")
   {
     alert("Enter the Last Name.");
     document.aspnetForm.ctl00_content1_txtlname.focus();
     return false;
   } 
   if (document.aspnetForm.ctl00_content1_txtlname.value!="")
         {   
             var alphaExp = /^[a-zA-Z ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtlname.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for Last Name.");
		        document.aspnetForm.ctl00_content1_txtlname.focus();
		        return false;
	         } 
	     }  
   /*------------------Validate Email_Id-----------------*/
    if(document.aspnetForm.ctl00_content1_txtemail.value=="")
    {
      alert("Enter Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false;
    }
    var str=document.aspnetForm.ctl00_content1_txtemail.value;
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(dot,(lat+2))==-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(" ")!=-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }    
/*------------------Validate Country-----------------*/   
  if (document.aspnetForm.ctl00_content1_ddlcountry.value=="-Select-")
   {
     alert("Select Country.");
     document.aspnetForm.ctl00_content1_ddlcountry.focus();
     return false;
   }   
//   if (document.aspnetForm.ctl00_content1_ddlcountry.value=="USA" || document.aspnetForm.ctl00_content1_ddlcountry.value=="Canada")
//   {
//   if (document.aspnetForm.ctl00_content1_ddlstate.value=="")
//   {
//     alert("Select State.");
//     document.aspnetForm.ctl00_content1_ddlstate.focus();
//     return false;
//   }  
//   }
//   else
//   {
//   if (document.aspnetForm.ctl00_content1_txtstate.value=="")
//   {
//     alert("Enter State.");
//     document.aspnetForm.ctl00_content1_txtstate.focus();
//     return false;
//   }  
//    if (document.aspnetForm.ctl00_content1_txtstate.value!="")
//         {   
//             var alphaExp = /^[a-zA-Z ]+$/;
//	         if(document.aspnetForm.ctl00_content1_txtstate.value.match(alphaExp))
//	         {
//        		
//	         }
//	         else
//	         {
//		        alert("Enter only letters for State.");
//		        document.aspnetForm.ctl00_content1_txtstate.focus();
//		        return false;
//	         } 
//	     }  
//   }
  
  
///*------------------Validate City-----------------*/
//   if (document.aspnetForm.ctl00_content1_txtcity.value=="")
//   {
//     alert("Enter the City.");
//     document.aspnetForm.ctl00_content1_txtcity.focus();
//     return false;
//   } 
//    if (document.aspnetForm.ctl00_content1_txtcity.value!="")
//         {   
//             var alphaExp = /^[a-zA-Z ]+$/;
//	         if(document.aspnetForm.ctl00_content1_txtcity.value.match(alphaExp))
//	         {
//        		
//	         }
//	         else
//	         {
//		        alert("Enter only letters for City.");
//		        document.aspnetForm.ctl00_content1_txtcity.focus();
//		        return false;
//	         } 
//	     }  
   /*------------------Validate Address----------------*/
//   if (document.aspnetForm.ctl00_content1_txtaddress.value!="")
//   {
//     alert("Enter the Address.");
//     document.aspnetForm.ctl00_content1_txtaddress.focus();
//     return false;
//   } 
//     if (document.aspnetForm.ctl00_content1_txtaddress.value!="")
//         {   
//             var alphaExp = /^[a-zA-Z0123456789#,. ]+$/;
//	         if(document.aspnetForm.ctl00_content1_txtaddress.value.match(alphaExp))
//	         {
//        		
//	         }
//	         else
//	         {
//		        alert("Enter only letters for address.");
//		        document.aspnetForm.ctl00_content1_txtaddress.focus();
//		        return false;
//	         } 
//	     }     
   /*------------------Validate Zipcode-----------------*/
//   if (document.aspnetForm.ctl00_content1_txtzip.value!="")
//  {   
////        alert("Enter value for Zipcode.");
////        document.aspnetForm.ctl00_content1_txtzip.focus();
////        return false;
////   }
//   if (document.aspnetForm.ctl00_content1_txtzip.value==0)
//   {   
//        alert("Enter valid value for Zipcode.");
//        document.aspnetForm.ctl00_content1_txtzip.focus();
//        return false;
//   }

//      var str=document.aspnetForm.ctl00_content1_txtzip.value;
//      var str1=document.aspnetForm.ctl00_content1_txtzip.value.length;
//      var iChars = "*|\":<>[]{}`\';()@&$#%.+-,";
//      for (var i = 0; i < str1; i++) 
//      {
//        if (iChars.indexOf(str.charAt(i)) != -1)
//        {
//          alert("Please enter a proper value for the Zipcode."); 
//          document.aspnetForm.ctl00_content1_txtzip.focus();
//          return false;
//        }
//      } 
//      }
//      /*------------------Validate PhoneNo-----------------*/
// if (document.aspnetForm.ctl00_content1_txtphone.value!="")
//   {   
////        alert("Enter Phone No.");
////        document.aspnetForm.ctl00_content1_txtphone.focus();
////        return false;
////   } 
//    if (document.aspnetForm.ctl00_content1_txtphone.value==0)
//   {   
//        alert("Enter valid value for Phone.");
//        document.aspnetForm.ctl00_content1_txtphone.focus();
//        return false;
//   } 
//      var str=document.aspnetForm.ctl00_content1_txtphone.value;
//      var str_array=str.split(",");
//      var length=str_array.length;
//      for (var i=0; i < length; i++)
//      {                       
//        if (isNaN(str_array[i]))
//        {
//           alert("Enter only number for PhoneNo.");
//           document.aspnetForm.ctl00_content1_txtphone.focus();
//           return false;
//        }
//      }
//      var str1=document.aspnetForm.ctl00_content1_txtphone.value.length;
//      var iChars = "*|\":<>[]{}`\';()@&$#%.+-";
//      for (var i = 0; i < str1; i++) 
//      {
//        if (iChars.indexOf(str.charAt(i)) != -1)
//        {
//          alert("Please enter a proper value for the Phone Number."); 
//          document.aspnetForm.ctl00_content1_txtphone.focus();
//          return false;
//        }
//      }         
//   }
///*------------------Validate Mobile No-----------------*/
//  
//    if (document.aspnetForm.ctl00_content1_txtmobile.value!="")
//   {   
////        alert("Enter valid value for Mobile.");
////        document.aspnetForm.ctl00_content1_txtmobile.focus();
////        return false;
////   } 
//     
//    if (document.aspnetForm.ctl00_content1_txtmobile.value==0)
//   {   
//        alert("Enter valid value for Mobile.");
//        document.aspnetForm.ctl00_content1_txtmobile.focus();
//        return false;
//   } 
//      var str=document.aspnetForm.ctl00_content1_txtmobile.value;
//      var str_array=str.split(",");
//      var length=str_array.length;
//      for (var i=0; i < length; i++)
//      {                       
//        if (isNaN(str_array[i]))
//        {
//           alert("Enter only number for MobileNo.");
//           document.aspnetForm.ctl00_content1_txtmobile.focus();
//           return false;
//        }
//      }
//      var str1=document.aspnetForm.ctl00_content1_txtmobile.value.length;
//      var iChars = "*|\":<>[]{}`\';()@&$#%.+-";
//      for (var i = 0; i < str1; i++) 
//      {
//        if (iChars.indexOf(str.charAt(i)) != -1)
//        {
//          alert("Please enter a proper value for the Mobile Number."); 
//          document.aspnetForm.ctl00_content1_txtmobile.focus();
//          return false;
//        }
//      }         
//   }
   /*------------------- Validate Choice-------------------*/
    var opts = document.aspnetForm.elements;
       var blnMark=false;
       
		for(var i=0;i<opts.length;i++)
		{
				if((opts[i].type=="checkbox") && (opts[i].name.search("chklist") != -1))
				{
				   		if(opts[i].checked)
						{
							blnMark = true;
							break;
						}
				}
		}
       
              	    if(blnMark==false)
					{
					alert("Select Receive Picture Option.");
			    	return false;
					
					}
/*------------------Validate Types-----------------*/   
  if (document.aspnetForm.ctl00_content1_ddltypes.value=="-Select-")
   {
     alert("Select Membership Type.");
     document.aspnetForm.ctl00_content1_ddltypes.focus();
     return false;
   } 
   /* -------------------- Validate Family Name --------------------*/
     if (document.aspnetForm.ctl00_content1_txtfamily.value=="")
   {
     alert("Enter the FamilyName.");
     document.aspnetForm.ctl00_content1_txtfamily.focus();
     return false;
   }   
   if (document.aspnetForm.ctl00_content1_txtfamily.value!="")
         {   
             var alphaExp = /^[a-zA-Z &,.']+$/;
	         if(document.aspnetForm.ctl00_content1_txtfamily.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for Family Name.");
		        document.aspnetForm.ctl00_content1_txtfamily.focus();
		        return false;
	         } 
	     } 
	     
	      /*------------------Validate Image1---------------if(document.getElementById('ctl00_content1_Literal1').innerHTML == "")
	      {*/
	      if (document.aspnetForm.ctl00_content1_hdval.value=="edit")
	      {
	      }
	      else
	      {	     
	      
           if (document.aspnetForm.ctl00_content1_FileUpload1.value=="" )
           {
             alert("Upload Family Picture.");
             document.aspnetForm.ctl00_content1_FileUpload1.focus();
             return false;
           } 
           
       }
     /*   -------------------- Validate Family Description --------------------*/
     if (document.aspnetForm.ctl00_content1_txtdescription.value=="")
   {
     alert("Enter the Family Description.");
     document.aspnetForm.ctl00_content1_txtdescription.focus();
     return false;
   }   
//   if (document.aspnetForm.ctl00_content1_txtdescription.value!="")
//         {   
//             var alphaExp = /^[a-zA-Z &,.'!]+$/;
//	         if(document.aspnetForm.ctl00_content1_txtdescription.value.match(alphaExp))
//	         {
//        		
//	         }
//	         else
//	         {
//		        alert("Enter only letters for Family Description.");
//		        document.aspnetForm.ctl00_content1_txtdescription.focus();
//		        return false;
//	         } 
//	     }  
   /*------------------Validate UserName-----------------*/
   if (document.aspnetForm.ctl00_content1_txtUserName.value=="")
   {
     alert("Enter the UserName.");
     document.aspnetForm.ctl00_content1_txtUserName.focus();
     return false;
   } 
    if (document.aspnetForm.ctl00_content1_txtUserName.value!="")
         {   
             var alphaExp = /^[a-zA-Z.,' ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtUserName.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for User Name.");
		        document.aspnetForm.ctl00_content1_txtUserName.focus();
		        return false;
	         } 
	     }     
    /*------------------Validate Password-----------------*/
   if (document.aspnetForm.ctl00_content1_txtpassword.value=="")
   {
     alert("Enter the Password.");
     document.aspnetForm.ctl00_content1_txtpassword.focus();
     return false;
   } 
  
   
/*------------------Validate Confirm Password-----------------*/
   if (document.aspnetForm.ctl00_content1_txtcpassword.value=="")
   {
     alert("Enter the Confirm Password.");
     document.aspnetForm.ctl00_content1_txtcpassword.focus();
     return false;
   } 
   if (document.aspnetForm.ctl00_content1_txtpassword.value != document.aspnetForm.ctl00_content1_txtcpassword.value)
   {
     alert("Password doesn't match.");
     document.aspnetForm.ctl00_content1_txtpassword.focus();
     return false;
   }    
   
   /*------------------------- Verify Age -----------------------*/
   
     var opts = document.aspnetForm.elements;
       var blnMark=false;
       
		for(var i=0;i<opts.length;i++)
		{
				if((opts[i].type=="checkbox") && (opts[i].name.search("chkage") != -1))
				{
				   		if(opts[i].checked)
						{
							blnMark = true;
							break;
						}
				}
		}
       
              	    if(blnMark==false)
					{
					alert("Confirm  Age.");
			    	return false;
					
					}
					
		/*------------------------- Verify Terms -----------------------*/
   
     var opts = document.aspnetForm.elements;
       var blnMark=false;
       
		for(var i=0;i<opts.length;i++)
		{
				if((opts[i].type=="checkbox") && (opts[i].name.search("chkaccep") != -1))
				{
				   		if(opts[i].checked)
						{
							blnMark = true;
							break;
						}
				}
		}
       
              	    if(blnMark==false)
					{
					alert("Check Terms & Conditions.");
			    	return false;
					
					}			
}

function chkEmailFields()
{
if (document.aspnetForm.ctl00_content1_txtname.value=="")
   {
     alert("Enter the Name.");
     document.aspnetForm.ctl00_content1_txtname.focus();
     return false;
   } 
   if (document.aspnetForm.ctl00_content1_txtname.value!="")
         {   
             var alphaExp = /^[a-zA-Z ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtname.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for Name.");
		        document.aspnetForm.ctl00_content1_txtname.focus();
		        return false;
	         } 
	     }  
 /*------------------Validate Email_Id-----------------*/
    if(document.aspnetForm.ctl00_content1_txtemail.value=="")
    {
      alert("Enter Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false;
    }
    var str=document.aspnetForm.ctl00_content1_txtemail.value;
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(at,(lat+1))!=-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(dot,(lat+2))==-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    }
    if (str.indexOf(" ")!=-1)
    {
      alert("Enter valid Email Address.");
      document.aspnetForm.ctl00_content1_txtemail.focus();
      return false
    } 
    /*------------------Validate State-----------------*/

    if (document.aspnetForm.ctl00_content1_txtstate.value!="")
   {
    
    if (document.aspnetForm.ctl00_content1_txtstate.value!="")
         {   
             var alphaExp = /^[a-zA-Z ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtstate.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for State.");
		        document.aspnetForm.ctl00_content1_txtstate.focus();
		        return false;
	         } 
	     }  
  }
  
  
/*------------------Validate City-----------------*/
   if (document.aspnetForm.ctl00_content1_txtcity.value!="")
   {
    
    if (document.aspnetForm.ctl00_content1_txtcity.value!="")
         {   
             var alphaExp = /^[a-zA-Z ]+$/;
	         if(document.aspnetForm.ctl00_content1_txtcity.value.match(alphaExp))
	         {
        		
	         }
	         else
	         {
		        alert("Enter only letters for City.");
		        document.aspnetForm.ctl00_content1_txtcity.focus();
		        return false;
	         } 
	     } 
	     } 
/*------------------Validate Phone-----------------*/
    if (document.aspnetForm.ctl00_content1_txtphone.value!="")
   {   
      
    if (document.aspnetForm.ctl00_content1_txtphone.value==0)
   {   
        alert("Enter valid value for Phone.");
        document.aspnetForm.ctl00_content1_txtphone.focus();
        return false;
   } 
      var str=document.aspnetForm.ctl00_content1_txtphone.value;
      var str_array=str.split(",");
      var length=str_array.length;
      for (var i=0; i < length; i++)
      {                       
        if (isNaN(str_array[i]))
        {
           alert("Enter only number for PhoneNo.");
           document.aspnetForm.ctl00_content1_txtphone.focus();
           return false;
        }
      }
      var str1=document.aspnetForm.ctl00_content1_txtphone.value.length;
      var iChars = "*|\":<>[]{}`\';()@&$#%.+-";
      for (var i = 0; i < str1; i++) 
      {
        if (iChars.indexOf(str.charAt(i)) != -1)
        {
          alert("Please enter a proper value for the Phone Number."); 
          document.aspnetForm.ctl00_content1_txtphone.focus();
          return false;
        }
      }   
      }
      
    /*------------------Validate comment-----------------*/        
    if (document.aspnetForm.ctl00_content1_txtcomment.value=="")
   {
     alert("Enter the Comment.");
     document.aspnetForm.ctl00_content1_txtcomment.focus();
     return false;
   }
    if (isWhitespace(document.aspnetForm.ctl00_content1_txtcomment.value) == true)
  {
   alert("Enter Comment text");
   document.aspnetForm.ctl00_content1_txtcomment.focus();
   return false;
  }    
}
var whitespace = " \t\n\r";

function isWhitespace (s)

{   var i;

     // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}