Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Validate Dates

Go to End



Community Member, 200 Posts

21 January 2014 at 1:45am

Ok got an issue, i'm trying to work out how to validate a form/datobject, i have a start date for a task and an end date for the task, what i want to do is on the edit task form if the FinDate field is populated that it checks that the value is not less than the StartDate.

I've tried,

if(isset($_POST['FinDate'])) {
		 	if($_POST['FinDate'] < $_POST['StartDate']) {
            	$form->addErrorMessage('FinDate', 'End Date cannot be fore start date', 'bad');
            	return $this->redirectBack();

but this just keeps firing when no date is added and if a date is added it doesn't validate.

Any help or pointers much appreciated.