I have a check out date and return date on my form. When the user selects the check out date, the form validates that the checkout date entered is no more than 7 days from the current date. Got that piece working fine. When the user selects the return date, I am trying to make the form validate that the return date is no more than 7 days from the selected check out date. Here is what I thought would work:
function msoxd_my_returnDate::OnValidate(eventObj)
{
var formOutDate = XDocument.DOM.selectSingleNode("//my:outDate");
var formReturnDate = XDocument.DOM.selectSingleNode("//my:returnDate");
if (eventObj.Site.nodeTypedValue != "")
{
var myDate = new Date(formOutDate.text);
myDate.setDate(myDate.getDate()+7);
if (myDate < formReturnDate.text)
{
XDocument.UI.Alert("Return date can not be more than 7 days from the checkout date.");
}
}
}