RTC script based validation
I have created a custom validatior to validate the dates. The scritp works fine. But the error message shown when the validation fails , it disappears when that date field goes out of focus. I want the error message to keep showing until the user enters the correct date ,how to accomplish this ? below is my validation script :
dojo.provide("org.example.DateValidator");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates
dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings
(function() {
var Severity = com.ibm.team.workitem.api.common.Severity;
var Status = com.ibm.team.workitem.api.common.Status;
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var DateValidator = dojo.declare("org.example.DateValidator", null, {
validate: function(attributeId, workItem, configuration) {
console.log("hi");
// Get the configuration parameters about the severity and error message of this validator
var severity= configuration.getChild("parameters").getStringDefault("severity", Severity.ERROR.name);
var message= configuration.getChild("parameters").getStringDefault("message", "");
var dateRequiredBy=dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
// Get the current attribute's value and make a Date object from it
var extendedDate=dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
console.log(dateRequiredBy);
console.log(extendedDate);
// Compare the two dates and make sure extendedDate is not earlier than dateRequiredBy
//If the dateRequiredBy > extendedDate = +ve else -ve
if (dojo.date.compare(dateRequiredBy, extendedDate) <= 0) {
return Status.OK_STATUS;
} else {
return new Status(Severity[severity], message);
}
}
});
})();