views:

31

answers:

1

Hi

I am trying to set up an onchange event within MS Dynamics CRM that brings up an alert if a date entered in a field falls outside of a specified range.

{
if (crmForm.all.fielddate.DataValue < 01/01/2010 || crmForm.all.fielddate.DataValue >= 01/01/2011)
{
alert("Specified date falls outside of the date range") ;
}
}

This doesnt seem to work, am I using the correct date format? or am I missing something out?

Thanks in advance for your help

Brett

A: 

You'll need to parse each value as a date before comparing:

if (Date.parse(fromDate) > Date.parse(toDate)) {
    alert("Specified date falls outside of the date range");
}
Focus