
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 > 30)
	{		
		alert("Maximum allowed length of Name is 30 !!!")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}		
	
	if(Trim(form.Address.value).length < 1)
	{
		alert("Enter Address")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}	
	if(Trim(form.Address.value).length > 200)
	{		
		alert("Maximum allowed length of Address is 200 !!!")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}		
	if(Trim(form.Email.value).length > 40)
	{		
		alert("Maximum allowed length of Email is 40 !!!")
		form.Email.select()
		form.Email.focus() 
		 
		return false	
	}		
	if(Trim(form.Phone.value).length < 1)
	{
		alert("Enter Phone")
		form.Phone.select()
		form.Phone.focus() 
		 
		return false	
	}	
	if(Trim(form.Phone.value).length > 50)
	{		
		alert("Maximum allowed length of Phone is 50 !!!")
		form.Phone.select()
		form.Phone.focus() 
		 
		return false	
	}			
	if(form.religion.value == "SelectReligion")
	{
		alert("Select Religion")		
		form.religion.focus() 
		 
		return false
	}	
	if(form.caste.value == "Select")
	{
		alert("Select Caste")		
		form.caste.focus() 
		 
		return false
	}	
	if(Trim(form.subcaste.value).length > 50)
	{		
		alert("Maximum allowed length of sub caste is 50 !!!")
		form.subcaste.select()
		form.subcaste.focus() 
		 
		return false	
	}		
	if(form.Gender.value == "false")
	{
		alert("Select Gender")		
		form.Gender.focus() 
		 
		return false	
	}
	if(form.Education_Level.value == "false")
	{
		alert("Select Education Level")		
		form.Education_Level.focus() 
		 
		return false
	}	
	if(Trim(form.Qualification.value).length > 250)
	{		
		alert("Maximum allowed length of Qualification is 250 !!!")
		form.Qualification.select()
		form.Qualification.focus() 
		 
		return false	
	}					
	
	if(form.Job_Category.value == "false")
	{
		alert("Select Job Category")		
		form.Job_Category.focus() 
		 
		return false
	}		
	if(Trim(form.JobDescription.value).length > 250)
	{		
		alert("Maximum allowed length of Job Description is 250 !!!")
		form.JobDescription.select()
		form.JobDescription.focus() 
		 
		return false	
	}	
	if(form.Monthly_Income.value == "false")
	{
		alert("Select Monthly Income")		
		form.Monthly_Income.focus() 
		 
		return false
	}		
	if(form.Height.value == "false")
	{
		alert("Select Height")		
		form.Height.focus() 
		 
		return false
	}
	if(form.Complexion.value == "false")
	{
		alert("Select Complexion")		
		form.Complexion.focus() 
		 
		return false
	}
	
	if(form.State_Country.value == "false")
	{
		alert("Select State/Country")		
		form.State_Country.focus() 
		 
		return false
	}

	if(form.State_Country.value != "Kerala")
	{
		if(Trim(form.City.value).length < 1)
		{
			alert("Enter District")
			form.City.select()
			form.City.focus() 
			
			return false	
		}		
		if(Trim(form.City.value).length > 20)
		{		
			alert("Maximum allowed length of District is 20 !!!")
			form.City.select()
			form.City.focus() 
			 
			return false	
		}			
	}
	else
	{
		if(form.City_Dropdown.value == "false")
		{
			alert("Select District")		
			form.City_Dropdown.focus()
			
			return false
		}		
	}
	
	if(Trim(form.NowResiding.value).length > 50)
	{		
		alert("Maximum allowed length of Now Residing is 50 !!!")
		form.NowResiding.select()
		form.NowResiding.focus() 
		 
		return false	
	}	

	if(form.Marital_Status.value == "false")
	{
		alert("Select Marital Status")		
		form.Marital_Status.focus() 
		 
		return false
	}
	if(!form.NoOfChildrenBoys.disabled)
	{	
		if(form.NoOfChildrenBoys.value == "false")
		{			
			alert("Select No Of Boys")		
			form.NoOfChildrenBoys.focus() 
		 
			return false				
		}	
	}
	if(!form.NoOfChildrenGirls.disabled)
	{	
		if(form.NoOfChildrenGirls.value == "false")
		{			
			alert("Select No Of Girls")		
			form.NoOfChildrenGirls.focus() 
		 
			return false				
		}	
	}	
	
	if(Trim(form.OfficialAddress.value).length > 200)
	{		
		alert("Maximum allowed length of Official Address is 200 !!!")
		form.OfficialAddress.select()
		form.OfficialAddress.focus() 
		 
		return false	
	}		
	

	if(Trim(form.Username.value).length < 5)
	{		
		alert("Username must have minimum 5 letters")
		form.Username.select()
		form.Username.focus() 
		 
		return false	
	}	
	
	if(Trim(form.Username.value).length > 20)
	{		
		alert("Password do not allowed to exceed 20 letters")
		form.Username.select()
		form.Username.focus() 
		 
		return false	
	}	
	if(Trim(form.Password.value).length < 5)
	{		
		alert("Password must have minimum 5 letters")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}	
	
	if(Trim(form.Password.value).length > 20)
	{		
		alert("Password do not allowed to exceed 20 letters")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}

		
}

function ManageChildrens(name1,name2,name3)
{

	if(name1.value=="Never married" || name1.value=="false")
	{
		name2.disabled = true
		name3.disabled = true
	}
	else
	{
		name2.disabled = false
		name3.disabled = false
	}

}

function ManageDistricts(name1,name2,name3)
{

	if(name1.value=="Kerala")
	{
		name2.disabled = false
		name2.style.display = 'block';
		name3.value = ""
		name3.disabled = true
		name3.style.display = 'none';
	}
	else
	{
		name2.disabled = true
		name2.style.display = 'none';
		name3.value = ""
		name3.disabled = false
		name3.style.display = 'block';
	}

}

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));
}
