﻿
function UVRequiredFieldTextBox(source)
{
    text_box = document.getElementById(source.controltovalidate);
	if (text_box == null) 
		return false; 
		
	text = text_box.value;
	
	if (text.length <= 0) 
        return false;
    if (text.match(/^\s*$/) != null)
        return false;

	return true;
}

function UVRequiredFieldList(source)
{
    drop_down = document.getElementById(source.controltovalidate);
	if (drop_down == null) 
		return false; 
		
	selected_index = drop_down.selectedIndex;
	if (selected_index == null || selected_index < 0) 
	    return false;
	    
    value = drop_down[selected_index].value;	    
    if (value == null || value.length <= 0) 
        return false;
    
    return true;
}

function UVRequiredFieldDate(source)
{
    date_ctrl = document.getElementById(source.controltovalidate);
	if (date_ctrl == null) 
		return false; 
    day_ctrl = document.getElementById(source.DayID);
    if (day_ctrl == null) 
        return false;
    day_txt = day_ctrl.value;
    if (day_txt == null || day_txt.length <= 0)
        return false;
        
    month_ctrl = document.getElementById(source.MonthID);
    if (month_ctrl == null) 
        return false;
    month_str = month_ctrl[month_ctrl.selectedIndex].value;    
    if (month_str == null || month_str.length <= 0) 
        return false;
    
    if (source.YearFormat == "DropDownYear") {
        year_ctrl = document.getElementById(source.YearID);
        if (year_ctrl == null) 
            return false;
        year_str = year_ctrl[year_ctrl.selectedIndex].value;
        if (year_str == null || year_str.length <= 0) 
            return false;
    }
    else if (source.YearFormat == "FreeFormYear") {
        year_ctrl = document.getElementById(source.YearID);
        if (year_ctrl == null) 
            return false;
        year_str = year_ctrl.value;
        if (year_str == null || year_str.length <= 0) 
            return false;
    }
    return true;
}

function UVRequiredFieldAcnList(source)
{
    var acnListCtrl = document.getElementById(source.controltovalidate);
	if (acnListCtrl == null) 
		return false; 
		
    if (acnListCtrl.CanBeNull == "False")
        return true;
    
    if (acnListCtrl.selectedIndex < 0) 
        return false;
    
    var selected_value = acnListCtrl.options[acnListCtrl.selectedIndex].value;
    if (selected_value == null || selected_value == "") 
        return false;
    var nullValue = acnListCtrl.NullValue;
    return (selected_value != nullValue);
}

