I have a form with the following fields : start date, duration (in days) & end date. I want the user to be able to enter EITHER a duration OR an end date and the other field will be automatically calculated according to this and the start date. Each field has an associated feedback label. However, simple as this seems, I’m having trouble pulling it off. Here’s what I’m going for in terms of behaviour: 

* If the start date is missing, the others are blanked and disabled.
* Changing either field results in an ajax update of both and the other field is calculated.
* When the form is submitted, the “calculated” field must be null (even though it displays the calculated value). The underlying domain object should have either a duration or an end date but not both.
* If a user removes the value of the calculated field, it just gets recalculated.
* If a user changes the value of the calculated field (for a valid value), the other field is blanked and is updated with a calculated value - it becomes the calculated field.
* If a user enters an invalid value into the calculated field this results in a feedback error and the non-calculated field doesn’t update.
* Similarly, if the user enters an invalid value into the non-calculated field the feedback error is shown and the calculated field is NOT updated (it remains based on the previous valid non-calculated field value).
* It would be nice to be able to chain these fields – have another duration / end date couple which use the first couple’s end date (calculated or not) as a start date.

Any pointers would be most appreciated as I’m having trouble seeing this clearly… 

Thanks, 

CN