I want to achieve the following, restrict changing a date field to further date from its current value, in Dynamics CRM via JavaScript.
Below is my JavaScript code, im pretty new to JavaScript Dynamics development, below is my code, by the way its not throwing an alert, is it coded properly? - apologies if the question doesnt make sense.
Why isn't it throwing an alert, when I enter a date future from current value?
function test(executionContext) {
formContext = executionContext.getFormContext();
var fielddate = formContext.getAttribute('fielddate').getValue();
if (fielddate != null) {
fielddate.setHours(0, 0, 0, 0);
//The current date
var currentDate = new Date();
currentDate.setHours(0, 0, 0, 0);
if (fielddate > currentDate) {
alert("You can't enter future date");
}
}
}