﻿// JScript File

//General Enquiry Form Validation

function TitleSelected(source, args)
{  
    
    var dropDownList = document.getElementById("ctl00_MasterContent_ddTitle");
	
	if (dropDownList != null)
	{
		args.IsValid = (dropDownList.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function ContactTimeSelected(source, args)
{
	var dropDownList = document.getElementById("ctl00_MasterContent_ddContactTime");

	if (dropDownList != null)
	{
		args.IsValid = (dropDownList.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function TermSelected(source, args)
{

    var dropDownList = document.getElementById("ctl00_MasterContent_ddLoanTerm");
        
	if (dropDownList != null)
	{
	    args.IsValid = (dropDownList.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function ResidentSelected(source, args)
{
    var dropDownList = document.getElementById("ctl00_MasterContent_ddResidentialStatus");

	if (dropDownList != null)
	{
		args.IsValid = (dropDownList.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function EmploymentSelected(source, args)
{
    var dropDownList = document.getElementById("ctl00_MasterContent_ddEmploymentStatus");

	if (dropDownList != null)
	{
		args.IsValid = (dropDownList.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function IsNumber(source, args)
{
    var ValidChars = "0123456789";
    var IsNumber = true;
    var Char;

    
    for (i = 0; i < args.Value.length && IsNumber == true; i++)
    { 
        Char = args.Value.charAt(i);

        if ((ValidChars.indexOf(Char) == -1) || (Char == ' '))
        {
            IsNumber = false;
        }
    }
    
    args.IsValid = IsNumber;
}

function IsCharacter(source, args)
{
    var ValidChars = "abc";
    var IsCharacter = true;
    var Char;

    for (i = 0; i < args.Value.length && IsCharacter == true; i++)
    { 
        Char = args.Value.charAt(i);

        if ((ValidChars.indexOf(Char) == -1) || (Char == ' '))
        {
            IsCharacter = false;
        }
    }
    
    args.IsValid = IsCharacter;
}

function DOBDaySelected(source, args)
{
	var dropDownListDay = document.getElementById("ctl00_MasterContent_ddDay");

	if (dropDownListDay != null)
	{
		args.IsValid = (dropDownListDay.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function DOBMonthSelected(source, args)
{
	var dropDownListDay = document.getElementById("ctl00_MasterContent_ddMonth");

	if (dropDownListDay != null)
	{
		args.IsValid = (dropDownListDay.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}

function DOBYearSelected(source, args)
{
	var dropDownListDay = document.getElementById("ctl00_MasterContent_ddYear");

	if (dropDownListDay != null)
	{
		args.IsValid = (dropDownListDay.selectedIndex > 0);
	}
	else
	{
		args.IsValid = false;
	}
}