# Javascript form validation for In place editting in scriptac

**URL:** <https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778>\
**Category:** Rails\
**Created:** [August 29, 2006, 7:47am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778 "2006-08-29T07:47:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 7:47am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/1 "2006-08-29T07:47:43Z")

</div>

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.

Regards,  
Jatinder

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 8:10am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/2 "2006-08-29T08:10:02Z")

</div>

Override the default method called by in\_place\_edit :

If you have \<%= in\_place\_editor\_field :object, :attribute %\>

Define the following in your controller :

private  
def set\_object\_attribute

- find by id
- update attribute
- render :text =\> @object.attribute  
end

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

-Pratik

On 8/29/06, Jatinder S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Jatinder
> 
> >

–  
rm -rf / 2\>/dev/null - [http://null.in](http://null.in)

Dont judge those who try and fail, judge those who fail to try…

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 8:12am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/3 "2006-08-29T08:12:06Z")

</div>

Found this.

[http://rails.techno-weenie.net/question/2006/7/17/how-do-i-extend-the-rails-code-to-do-what-i-want](http://rails.techno-weenie.net/question/2006/7/17/how-do-i-extend-the-rails-code-to-do-what-i-want)

On 8/29/06, Pratik [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - render :text =\> @object.attribute
> 
> > > >
> 
> –  
> rm -rf / 2\>/dev/null - [http://null.in](http://null.in)
> 
> Dont judge those who try and fail, judge those who fail to try…

–  
rm -rf / 2\>/dev/null - [http://null.in](http://null.in)

Dont judge those who try and fail, judge those who fail to try…

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 8:38am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/4 "2006-08-29T08:38:21Z")

</div>

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.

Email: 

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.

Regards,  
Jatinder

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 9:06am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/5 "2006-08-29T09:06:24Z")

</div>

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.

Thanks,  
Pratik

On 8/29/06, Jatinder S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > def set\_object\_attribute  
> > On 8/29/06, Jatinder S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > Regards,

–  
rm -rf / 2\>/dev/null - [http://null.in](http://null.in)

Dont judge those who try and fail, judge those who fail to try…

---

<div class="post-metadata">

**Author:** ![Jatinder\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e4f/32.png) [@Jatinder\_S](https://www.ruby-forum.com/u/Jatinder_S)\
**Post date:** [August 29, 2006, 9:32am UTC](https://www.ruby-forum.com/t/javascript-form-validation-for-in-place-editting-in-scriptac/66778/6 "2006-08-29T09:32:26Z")

</div>

Yes I would definately add validations at server level too.  
I will look through unobtrusive js plugin.

Thanks!

-Jatinder
