Board Logo

Limiting dates to a given range
paladin - 5/5/2010 at 04:32 PM

This is a first post so if it's out of place, bear with me...

I have seen a couple of posts on this issue with no responses. I have implemented limits and thought I would share my results in case they may be useful to others.

In my project, I needed to make the limits visible to the user so the code uses the form elements containing those values. This is not required. Setting up the 'onChange' function is the only real requirement. From there you can decide how to implement this.

Below is my change summary with a very 'thin' example. Changes are required to calendar_db.js (my choice for my project) to create a 'hook' to let you know when a date has been selected.

I am attaching my revised calendar_dsx.js code and would be interested in knowing if anyone found it
1. Usable
2. Functional
3. Useful




2010-May-5 jrw Added code to support to set and enforce limits on
selected dates.
1. User must define a function to be called to
handle the 'onChange' event. This function must
implement the enforcement of limits.
2. User must define global vars and save each tcal
object using the limit feature.
3. User must create input elements to contain the
limit values with unique IDs within the page.
4. User musr create 'Mindate' and 'MaxDate' elements
in A_TCALDEF containing the IDs of the input
elements described in #3 above.
5. User must include an 'onChange' config argument
to tcal passing a reference to the event handler
specified in #1 above.

EXAMPLE:

<script ... src="calendar_ds.js">
<script...>
A_TCALDEF.MinDate = 'firstdate';
A_TCALDEF.MaxDate = 'lastdate';

var oSTARTDATE;
var oENDDATE

function f_ChkLimit(that)
{
:
:
}
</script>
:
:
oSTARTDATE = tcal({ ... ,'onChange': f_ChkLimit }
:
:
<input ... id="firstdate" ...>
<input ... id="lastdate" ...>
:
:


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/