
function validate(form)
{

	if(Trim(form.Name.value).length < 1)
	{
		alert("Enter Name")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}	
	if(Trim(form.Name.value).length > 50)
	{		
		alert("Maximum allowed length of Name is 50 !!!")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}			
	if(Trim(form.ResidenceAddress.value).length < 1)
	{
		alert("Enter Residence Address")
		form.ResidenceAddress.select()
		form.ResidenceAddress.focus() 
		 
		return false	
	}	
	if(Trim(form.ResidenceAddress.value).length > 250)
	{		
		alert("Maximum allowed length of Residence Address is 250 !!!")
		form.ResidenceAddress.select()
		form.ResidenceAddress.focus() 
		 
		return false	
	}	
	if(Trim(form.ResidencePhone.value).length > 50)
	{		
		alert("Maximum allowed length of Residence Phone is 50 !!!")
		form.ResidencePhone.select()
		form.ResidencePhone.focus() 
		 
		return false	
	}	
	
	if(Trim(form.ResidenceMobile.value).length > 50)
	{		
		alert("Maximum allowed length of Mobile is 50 !!!")
		form.ResidenceMobile.select()
		form.ResidenceMobile.focus() 
		 
		return false	
	}	
	if(Trim(form.ResidenceEmail.value).length > 50)
	{		
		alert("Maximum allowed length of Email is 50 !!!")
		form.ResidenceEmail.select()
		form.ResidenceEmail.focus() 
		 
		return false	
	}	
	if(Trim(form.AbroadAddress.value).length > 250)
	{		
		alert("Maximum allowed length of Abroad Address is 250 !!!")
		form.AbroadAddress.select()
		form.AbroadAddress.focus() 
		 
		return false	
	}	
	if(Trim(form.AbroadPhone.value).length > 50)
	{		
		alert("Maximum allowed length of Phone is 50 !!!")
		form.AbroadPhone.select()
		form.AbroadPhone.focus() 
		 
		return false	
	}
	if(Trim(form.AbroadMobile.value).length > 50)
	{		
		alert("Maximum allowed length of Mobile is 50 !!!")
		form.AbroadMobile.select()
		form.AbroadMobile.focus() 
		 
		return false	
	}	
	if(Trim(form.AbroadEmail.value).length > 50)
	{		
		alert("Maximum allowed length of Email is 50 !!!")
		form.AbroadEmail.select()
		form.AbroadEmail.focus() 
		 
		return false	
	}	
	if(Trim(form.MaritalStatus.value).length > 50)
	{		
		alert("Maximum allowed length of Marital Status is 50 !!!")
		form.MaritalStatus.select()
		form.MaritalStatus.focus() 
		 
		return false	
	}	
	if(Trim(form.DOB.value).length > 50)
	{		
		alert("Maximum allowed length of Date of Birth is 50 !!!")
		form.DOB.select()
		form.DOB.focus() 
		 
		return false	
	}	
	if(Trim(form.WeddingDate.value).length > 50)
	{		
		alert("Maximum allowed length of Wedding Date is 50 !!!")
		form.WeddingDate.select()
		form.WeddingDate.focus() 
		 
		return false	
	}	
	if(Trim(form.SpouseName.value).length > 50)
	{		
		alert("Maximum allowed length of Spouse Name is 50 !!!")
		form.SpouseName.select()
		form.SpouseName.focus() 
		 
		return false	
	}	
	if(Trim(form.SpouseDOB.value).length > 50)
	{		
		alert("Maximum allowed length of Spouse DOB is 50 !!!")
		form.SpouseDOB.select()
		form.SpouseDOB.focus() 
		 
		return false	
	}	
	if(Trim(form.JobDetails.value).length > 250)
	{		
		alert("Maximum allowed length of Job Details is 250 !!!")
		form.JobDetails.select()
		form.JobDetails.focus() 
		 
		return false	
	}	
	if(Trim(form.OfficeAddress.value).length > 250)
	{		
		alert("Maximum allowed length of Office Address is 250 !!!")
		form.OfficeAddress.select()
		form.OfficeAddress.focus() 
		 
		return false	
	}	
	if(Trim(form.OfficePhone.value).length > 50)
	{		
		alert("Maximum allowed length of Office Phone is 50 !!!")
		form.OfficePhone.select()
		form.OfficePhone.focus() 
		 
		return false	
	}	
	if(Trim(form.OfficeEmail.value).length > 50)
	{		
		alert("Maximum allowed length of Office Email is 50 !!!")
		form.OfficeEmail.select()
		form.OfficeEmail.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildName1.value).length > 50)
	{		
		alert("Maximum allowed length of Child Name is 50 !!!")
		form.ChildName1.select()
		form.ChildName1.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildDOB1.value).length > 50)
	{		
		alert("Maximum allowed length of Date of birth is 50 !!!")
		form.ChildDOB1.select()
		form.ChildDOB1.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildInstitution1.value).length > 250)
	{		
		alert("Maximum allowed length of Institution is 250 !!!")
		form.ChildInstitution1.select()
		form.ChildInstitution1.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildName2.value).length > 50)
	{		
		alert("Maximum allowed length of Child Name is 50 !!!")
		form.ChildName2.select()
		form.ChildName2.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildDOB2.value).length > 50)
	{		
		alert("Maximum allowed length of Date of birth is 50 !!!")
		form.ChildDOB2.select()
		form.ChildDOB2.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildInstitution2.value).length > 250)
	{		
		alert("Maximum allowed length of Institution is 250 !!!")
		form.ChildInstitution2.select()
		form.ChildInstitution2.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildName3.value).length > 50)
	{		
		alert("Maximum allowed length of Child Name is 50 !!!")
		form.ChildName3.select()
		form.ChildName3.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildDOB3.value).length > 50)
	{		
		alert("Maximum allowed length of Date of birth is 50 !!!")
		form.ChildDOB3.select()
		form.ChildDOB3.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildInstitution3.value).length > 250)
	{		
		alert("Maximum allowed length of Institution is 250 !!!")
		form.ChildInstitution3.select()
		form.ChildInstitution3.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildName4.value).length > 50)
	{		
		alert("Maximum allowed length of Child Name is 50 !!!")
		form.ChildName4.select()
		form.ChildName4.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildDOB4.value).length > 50)
	{		
		alert("Maximum allowed length of Date of birth is 50 !!!")
		form.ChildDOB4.select()
		form.ChildDOB4.focus() 
		 
		return false	
	}	
	if(Trim(form.ChildInstitution4.value).length > 250)
	{		
		alert("Maximum allowed length of Institution is 250 !!!")
		form.ChildInstitution4.select()
		form.ChildInstitution4.focus() 
		 
		return false	
	}				
	if(Trim(form.FlashNews.value).length > 1000)
	{		
		alert("Maximum allowed length of Flash News is 1000 !!!")
		form.FlashNews.select()
		form.FlashNews.focus() 
		 
		return false	
	}	
	if(Trim(form.Username.value).length < 5)
	{
		alert("Username must have minimum 5 characters ")
		form.Username.select()
		form.Username.focus() 
		 
		return false	
	}	
	if(Trim(form.Username.value).length > 50)
	{		
		alert("Maximum allowed length of Username is 50 !!!")
		form.Username.select()
		form.Username.focus() 
		 
		return false	
	}
	if(Trim(form.Password.value).length < 5)
	{
		alert("Password must have minimum 5 characters ")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}	
	if(Trim(form.Password.value).length > 50)
	{		
		alert("Maximum allowed length of Password is 50 !!!")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}		
										
	form.submitbutton.disabled = true;
	return true;
}
function checkNumeric(objValue)
{
	 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              {                            
                //alert("\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }
	      else
	      {
		return true;
              }
                         
           
}
function searchSpace(name)
{
	var str = name.value
	
	if( str.indexOf(" ",0) >= 0 )
	{
		alert ("Please do not use any space.");
		name.focus();
		name.select();
		return false;
	}
	else
	{return true;}
}
function LTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...
            var j=0, i = s.length;
            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }
        return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in whitespace
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...
            var i = s.length - 1;       // Get length of string
            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
// Trims all spaces to the left and right of a specific string by calling RTim
// and LTrim
function Trim(str)
{
        return RTrim(LTrim(str));
}
