Hi there,
I wan to validate the Birthdate Field and when validated then set the value to new filed Age
and if less the 18 the display message .
I am getting Error Unable to get property getFullYear.
How can I do this
function CalculateAge(birthdate, ondate)
{
// if ondate is not specified consider today's date
if (ondate == null) { ondate = new Date(); }
// if the supplied date is before the birthday returns 0
if (ondate < birthdate) { return 0; }
var age = ondate.getFullYear()-birthdate.getFullYear();
if (birthdate.getMonth() > ondate.getMonth() || (birthdate.getMonth() == ondate.getMonth() && birthdate.getDate() > ondate.getDate()))
{ age--; }
Xrm.Page.getAttribute("new_age").setValue(age);
if (age > 18) {
alert('msg');
}
}