End date should be greater than start date
![]()
Amit Girme (11●3●19●27)
| asked Feb 04 '13, 9:06 a.m.
edited Apr 02 '13, 4:01 a.m. by Ralph Schoon (62.7k●3●36●43)
Hi All,
I have created two custom attributes start date and end date. When i create WI My end date should be greater than Start date.
for eg start date - 15/02/2013 then end date - 16/02/2013
If my end date is less then 15/02/2013 then i should get error message.
How can i do this??
Regards,
Amit
|
2 answers
![]() var DateValidator = dojo.declare("org.example.DefectDateValidate", null, { validate: function(attributeId, workItem, configuration) { var severity = "ERROR"; var message = "your error msg here"; var wi_type = workItem.getValue(WorkItemAttributes.TYPE); if (wi_type != "your work item type here") { // we may want to restrict the validation to a given type only return Status.OK_STATUS; } var beginDate = dojo.date.stamp.fromISOString(workItem.getValue("your begin date")); var endDate= dojo.date.stamp.fromISOString(workItem.getValue("your end date")); // Compare the two dates and make sure endDate is not earlier than beginDate if (dojo.date.compare(endDate, beginDate) >= 0) { return Status.OK_STATUS; }else if((beginDate == null) && (endDate == null)) { return Status.OK_STATUS; }else if((beginDate != null) && (endDate == null)) { return Status.OK_STATUS; }else { return new Status(Severity[severity], message); } } }); })(); |