Field validation on leave

This is actually pretty close to what I am looking for. I should spend some time understanding what this is doing so I can know what I need to modify.