Hello,
I followed this thread: http://www.hyfinity.net/wmforum/showthread.php?tid=72&highlight=date+constraint.
It works when all the fields are on the same form.
However, how can I make it work when the the fields are on different partial pages that stem from the same main form?
I followed this thread: http://www.hyfinity.net/wmforum/showthread.php?tid=72&highlight=date+constraint.
It works when all the fields are on the same form.
However, how can I make it work when the the fields are on different partial pages that stem from the same main form?
RE: Date Constraints
I don+?+?+?t think the approach should be any different when the fields are on partial pages as opposed to directly on a main page.
The main thing you will need to do is make sure that both fields have loaded in before calling the setDateConstraint function.
For example, you could wrap the call in a function, and then call this function as an onload event from each partial page.
function applyDateRestriction() { //make sure both fields are avaialble if (dojo.byId('firstDate') && dojo.byId('secondDate')) { hyf.calendar.setDateConstraint('secondDate', 'Minimum', 'firstDate'); } }
I have also attached a simple WebMaker 7 project export that illustrates this approach.
I hope this helps.
Please let me know if you have any more questions on this.
Regards,
Gerard
RE: Date Constraints
RE: Date Constraints
I am getting the following error when I run the application that uses the perform script - date validation.
How can I resolve this?
TypeError: calendarConfig is undefined
calendarConfig.minExclusive = restrictionDateValue;
RE: Date Constraints
Are you getting that error every time or just occasionally?
I have done some more testing on this today, and have seen that type of error occasionally.
As the timing of the ajax calls is not guaranteed I think in some cases both calls are finishing at about the same time, and so causing the restriction process to happen twice. At one of these calls though the calendar information has not yet been correctly set up which leads to this error.
To resolve this, you could look at improving the checking in the applyDateRestriction function to make sure the needed calendar config is also ready. eg
function applyDateRestriction() { //make sure both fields are available and the calendar config present if (dojo.byId('firstDate') && dojo.byId('secondDate') && hyf.calendar.config['secondDate']) { hyf.calendar.setDateConstraint('secondDate', 'Minimum', 'firstDate'); } }
Alternatively, you could look at keeping track of which partial pages have loaded, and then only apply the restrictions once they have all been rendered.
I hope this helps.
Regards,
Gerard