Javascript form validation for In place editting in scriptaculous ?

Is there a way by which I can do form validation for form generated by In Place Editting of scritaculous?

The reason is, I want to avoid server roundtrip for checks which I can perform at browser.



Override the default method called by in_place_edit :

If you have <%= in_place_editor_field :object, :attribute %>

Define the following in your controller :

def set_object_attribute
- find by id
- update attribute
- render :text => @object.attribute

This will perform the validation, but won't display the errors
however. You might want to play around with RJS to do so.


Found this.

Thanks for sharing the link Pratik.

The link explains how do I extend rails code to perform certain validations for in place editing control at server side; I am looking for performing validations at client side.

for e.g.


On submission of above form, validate_form javascript method should be called to perform javascript form validation, only then form should be submitted.

I was wondering if scriptaculous IPE allows that? something like onSubmitFormValidate as one of the options argument in IPE would have been great.



I usually never perform client side validation. As it can be fooled
easily, and you might end up with a lot of junk code in your database.
So, even if you're doing client side validation, server side
validation is a must.

Try looking into unobtrusive js plugin. That might be useful.


Yes I would definately add validations at server level too.

I will look through unobtrusive js plugin.