﻿/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Author:			aleonard
Date:			2007.06.29
Description:	Javascript validation resource file for the application.
				This script is compiled into the assembly
Revisions:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/

/*
-------------------------------------------------------------------------------
Author:			aleonard
Date:			2007.06.29
Description:	Validates a date
Parameters:
	sender		Object that initiated the validation (ASP.NET validator)
	args		
-------------------------------------------------------------------------------
*/
function ValidateDate(sender, args)
{
	var dt = new Date();
	if (dt.isDate(args.Value))
	{
		var strFormat = new String();
		//Check if a format has been specified
		if(sender.attributes('formatstring'))
		{
			strFormat = sender.attributes('formatstring').nodeValue;
		}
		else
		{
			strFormat = 'MM/dd/yyyy';
		}
		//Since the sender is a validator control, the 'ControlToValidate' attribute
		//can be used to set a value to the validated control
		document.getElementById(sender.attributes('controltovalidate').nodeValue).value = dt.format(strFormat);
		args.IsValid = true;
	}
	else
	{
		args.IsValid = false;
	}
}
