Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
FormAPI to determine number of days between dates
System
Someone sent me a private message asking how to compare two dates in a template (for instance to ensure one occurs before the other). I had done something like this (not sure it's totally accurate):
function daysDiff( d1, d2 )
{
diffMilli = d2.getTime() - d1.getTime();
return( Math.round( diffMilli / 86400000 ));
}
This should ensure /SomeField is not more than 365 days into the future, but you could also check against another field on the form (say on an onSave event):
var someDate = new Date( IWDatacapture.getItem( "/SomeField" ).getValue());
if ( daysDiff( new Date(), someDate ) > 365 )
{
alert( "SomeField must be fewer than 365 days into the future." );
return( false );
}
Find more posts tagged with
Comments
There are no comments yet