﻿function ValidateDDL(source, arguments) 
{
    var ddl = document.getElementById(source.controltovalidate);
    var selectedOption = null;
    for(i = 0; i < ddl.options.length; i++)
    {
        if(ddl.options[i].selected)
        {
            selectedOption = ddl.options[i];
            break;
        }
    }
    
    if(selectedOption == null || selectedOption.value == "-1")
    {
        arguments.IsValid =  false;
        return;
    }
    
    
    arguments.IsValid = true;
}
    
function ValidateDDLIfNotEmpty(source, arguments) 
{
    var ddl = document.getElementById(source.controltovalidate);
    
    if(ddl.options.length < 2)
    {
        arguments.IsValid = false;
        return;
    }
    
    
    var selectedOption = null;
    for(i = 0; i < ddl.options.length; i++)
    {
        if(ddl.options[i].selected)
        {
            selectedOption = ddl.options[i];
            break;
        }
    }
    
    if(selectedOption == null || selectedOption.value == "-1")
    {
        arguments.IsValid =  false;
        return;
    }
    
    
    arguments.IsValid = true;
}
    