this is my code and i dont want to use two functions and want to minimise it
function validatePODateOnChange() {
//Expected PO Date Validation(Expected PO Date Cannot be of past date).
try {
if (Xrm.Page.context.client.getClient() == "Web" || Xrm.Page.context.client.getClient() == "Outlook") {
var expectedPODate = Xrm.Page.getAttribute("ac_expectedpodate").getValue();
if (expectedPODate != null) {
var currDate = new Date(new Date().getYear(), new Date().getMonth(), new Date().getDate());
var expectedPODateVal = new Date(expectedPODate.getYear(), expectedPODate.getMonth(), expectedPODate.getDate());
if (expectedPODateVal < currDate) {
Xrm.Page.getControl("ac_expectedpodate").setNotification("Expected PO date cannot be of past date...");
}
else {
Xrm.Page.getControl("ac_expectedpodate").clearNotification();
}
}
}
}
catch (err) {
alert(err.message.toString());
}
}
function validateResponseExpectedDateOnChange() {
//Expected Response Date(Expected Response Date cannot be of past date)
try {
if (Xrm.Page.context.client.getClient() == "Web" || Xrm.Page.context.client.getClient() == "Outlook") {
var responseExpectedDate = Xrm.Page.getAttribute("ac_expectedresponsedate").getValue();
if (responseExpectedDate != null) {
var currDate = new Date();
var currDateVal = new Date(currDate.getYear(), currDate.getMonth(), currDate.getDate());
var responseExpectedDateVal = new Date(responseExpectedDate.getYear(), responseExpectedDate.getMonth(), responseExpectedDate.getDate());
if (responseExpectedDateVal < currDateVal) {
Xrm.Page.getControl("ac_expectedresponsedate").setNotification("Expected Response Date cannot be of past date...");
}
else {
Xrm.Page.getControl("ac_expectedresponsedate").clearNotification();
}
}
}
}
catch (err) {
alert(err.message.toString());
}
}