MonoForge

jcoglan / acceptance-old

acceptance-old

Public

A port of Ojay.Forms to Prototype, with a Rails plugin to generate client-side validation code

20 filesupdated Jun 27, 2026

README

== Acceptance

Copyright (c) 2008 James Coglan, released under the MIT license

Acceptance is a port of the Ojay.Forms validation API to work with the Prototype library. This plugin provides hooks into your Rails application that can automatically generate client-side validation code from your Rails models. Information on the client-side API can be found at the Ojay project site:

http://ojay.othermedia.org/articles/forms.html

The only difference here is that you need to call <tt>Acceptance()</tt> instead of <tt>Ojay.Forms()</tt> when using the API. All the other function calls are identical. For example:

Acceptance(function() { with(this) { form('the-form') .requires('username').toHaveLength({minimum: 6}) .expects('email_confirmation').toConfirm('email'); }});

Refer to the Ojay site for the rest of the API. You can use this plugin with the original Ojay client-side library by putting this in your environment.rb:

Acceptance.adapter = :ojay

To have Acceptance generate client-side code for you, simply replace any calls to +form_for+ with +acceptance_form_for+. A script tag will be added after the form containing rules for any fields in the form that can be checked client-side without making a server request.

Before

<% form_for(@user) do |f| %> ... <% end %>

After

<% acceptance_form_for(@user) do |f| %> ... <% end %>

The following validation types are supported, with a few limitations:

validates_acceptance_of validates_confirmation_of validates_exclusion_of validates_format_of validates_inclusion_of validates_length_of validates_numericality_of validates_presence_of validates_size_of