Field-by-field confirmation popup

Shauna wrote:

Hi, I've searched and can't find a straightforward answer to my particular need. There are actually two related situations I need to find solutions for.

1. On a data entry form, for certain fields I want to do some validation right after the user leaves the field (rather than wait until the entire form is completed). If invalid, I want a modal window to pop up with my composed message in it and an OK button. When the user presses OK, control returns to the data entry form remaining in the problem field.

2. On a data entry form where an existing record is being updated, if the user changes a non-empty field to different value in any field (with a few exceptions), I want a modal window to pop up with a confirmation message and OK and Cancel buttons. When the user presses OK, control continues normally to the next field on the form. When Cancel, the user's change will be reversed (restoring the previous value to the field) and control remains in the problem field.

Is there one simple way to do each of these two things (hopefully DRY for the second one)?

Thanks, Shauna

-- Posted via http://www.ruby-forum.com/

I have actually been working on a system that creates a 'live-form' that uses AJAX to do real time validations and some other funky stuff. It's still pretty rough around the edges, and real work keeps preventing me from extracting it for the moment, but it is possible.

The gist of the way it works is to create a form_observer that calls a form validation method. This method returns an RJS template that updates the page to indicate errors and provide some other useful feedback. This approach has a bunch of pitfalls, but when it works well, it's wonderful.

Hopefully I'll be able to write this up in more detail soon, so watch this blog for details... www.sciwerks.com/blog