Soft Validation

Hi,

I’m a new-ish part time rails dev, self taught, so I apologize if this
is a
question that I should know the answer to. I’ve had no luck finding a
way
to implement soft validations in rails (i.e. the form will give you a
warning that certain fields are not right and an option to go back an
correct them or to submit the incorrect information).

We have a demographics form that asks for sensitive information–so we
would like to let people know if they simply skipped a question
accidentally, but permits them to submit the form without having
answered
all of the questions should they prefer. In case it matters–we’re only
looking at radio buttons and check boxes, and we’re only checking to see
if
the questions were answered.

The only thing I was able to find was a rubyforge gem abandoned over six
years ago.

Does anyone know if there is any way to do this with rails?

Thanks for any help!

Mike

On Apr 14, 2014, at 3:30 PM, Michael R. wrote:

Hi,

I’m a new-ish part time rails dev, self taught, so I apologize if this is a
question that I should know the answer to. I’ve had no luck finding a way to
implement soft validations in rails (i.e. the form will give you a warning that
certain fields are not right and an option to go back an correct them or to submit
the incorrect information).

We have a demographics form that asks for sensitive information–so we would
like to let people know if they simply skipped a question accidentally, but
permits them to submit the form without having answered all of the questions
should they prefer. In case it matters–we’re only looking at radio buttons and
check boxes, and we’re only checking to see if the questions were answered.

The only thing I was able to find was a rubyforge gem abandoned over six years
ago.

Does anyone know if there is any way to do this with rails?

If you do these optional validations with JavaScript, then they can be
independent of the business rules that Rails enforces (the ones that
absolutely stop submission). That might be a way to get around this
issue.

Walter

On Mon, Apr 14, 2014 at 3:30 PM, Michael R. [email protected]
wrote:

we would
like to let people know if they simply skipped a question accidentally, but
permits them to submit the form without having answered all of the questions
should they prefer.

Not Rails-specific, but: why not simply allow “prefer not to answer”
as an option? That way, you can easily enforce that they must give
some kind of response to all questions, but they don’t have to
reveal personal info if they don’t want to.


Dave A., freelance software developer (details @ www.Codosaur.us);
see also www.PullRequestRoulette.com, Blog.Codosaur.us, www.Dare2XL.com

Hi all,

Thanks for the suggestions. I was hoping to avoid client-side
validations
just because it means replicating a lot of work already done (and my
JS/JQuery is not up to snuff, but I should take it as an opportunity to
work on that). That will be the route I take, I guess.

Dave: the ‘I prefer not to answer’ is the best option if we assume
humans
act rationally. However, if you state that as an option many people
assume
there is some reason that they should not answer and they not only
choose
not to answer but become more suspicious and tend to drop out of the
study. Also, if personal experience is generalizable, many people are
lazy
and will just click that if they don’t to look up an answer. For these
reasons we’d like to avoid cluing them in to the fact that they can skip
the question, but we want to let them skip it if they have an actual
objection to providing the information.

Max: Yes, I plan to keep the server side validations in check for
everything important. These question pertain mostly to demographic
information–household income and the like–that people may have
objections
to sharing, and that won’t destroy our data if they’re absent–just
present
a less rich picture.

Once again, thanks all for the feedback. It’s encouraging as to someone
starting freelance work.

Mike

Hi Mike,

it seems like you want to do some validation to improve the user
experience, give them some feedback etc.

Without knowing the exact use cases I would go with a combination of
client- and server-side validation. On client’s side you can go with one
of
the various jQuery form validation plugins that suits your needs. On the
other hand it’s not that big of a deal to write some custom JavaScript
to
check for some basic things, like completion of questions etc.

But I would like to stress the point that you definitely should validate
the most important things on the server-side (validation in models,
see Active Record Validations — Ruby on Rails Guides). To be
absolutely sure, you should check the rules on client-side again on
server
side.

Good luck!
Max

Am Montag, 14. April 2014 21:30:51 UTC+2 schrieb Michael R.:

You might be able to utilize html5 validation, all depends on the
requirements. Web Forms - Dive Into HTML5