var date1 = new Date(Xrm.Page.getAttribute(“firstDate”).getValue();
var date2 = new Date(Xrm.Page.getAttribute(“secondDate”).getValue();
In cannot do this in CRM event script
if (date < date2) // this script will not run and will exit executinn of the function.
you have to take the diff and see if it is less than zero(0)
if ( (date – date2) < 0) // this will actually fetch the difference in millisenconds and will be accurate.
First choice was to use Google DateJS library. As usual very drveloper friendly. I used Date JS, EN culture for formating date for error messages. One big issue I ran into with the library was that getAttribute would not fetch the date entered value on the form, would only fetch the date when form loaded. This was very annoying and had to dump DateJS. (http://code.google.com/p/datejs/ )
Enjoy and let me know if you see the behaviors of these libraries within CRM event model work any better or worse.
NOTE: I did not check out JQuery or JQuery UI to find a solution for date formatting, since I got my solution from “F is for Format”.