# How can I put the error messages generated by the validation

**URL:** <https://www.ruby-forum.com/t/how-can-i-put-the-error-messages-generated-by-the-validation/53673>\
**Category:** Rails\
**Created:** [February 13, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/how-can-i-put-the-error-messages-generated-by-the-validation/53673 "2006-02-13T17:04:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jochen\_Dress](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@Jochen\_Dress](https://www.ruby-forum.com/u/Jochen_Dress)\
**Post date:** [February 13, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/how-can-i-put-the-error-messages-generated-by-the-validation/53673/1 "2006-02-13T17:04:52Z")

</div>

Hello,

I’m a newbie, coming from Visual FoxPro - a database centric and object  
orientated scripting language with a rich set of graphical user  
interface controlls. Lerning ruby on rails means for me to lern html as  
well. But now to my

problem:  
The validation errors are listed at the top of the page without any  
order. Depending on the size of the form and the numbers of errors  
listed the data entry fields containing the corresponding invalid data  
eventually are out of sight. If the user corrected the value of a field  
the corresponding error message should indicate that something was done.

idea:

1. Bring the error messages into a meaningful order (there have already  
been posts covering this task)
2. Display the error messages in a side frame with it’s own scrollbar.
3. Make a specific part of the message interactive, so a click of the  
user on this part will take him right a way to the corresponding data  
entry field.
4. Change the color of the error message if the field entry was changed.

implementation:  
???

Thanks in advance

Jochen

---

<div class="post-metadata">

**Author:** ![Jochen\_Dress](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@Jochen\_Dress](https://www.ruby-forum.com/u/Jochen_Dress)\
**Post date:** [February 13, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/how-can-i-put-the-error-messages-generated-by-the-validation/53673/2 "2006-02-13T21:02:47Z")

</div>

For now, you can use my plugin (see signature) to order your fields. I  
was  
only 3 days into Ruby/Rails when I wrote it so it definitely needs to be  
refactored. Eventually, I’ll submit it as patch. As for the display and  
location, CSS and Javascript are your friends.

Another option if you want to get personal, is to generate your own  
error  
handling/display using the error\_on function.

Bob S.  
[http://www.railtie.net/](http://www.railtie.net/)

---

<div class="post-metadata">

**Author:** ![Jochen\_Dress](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@Jochen\_Dress](https://www.ruby-forum.com/u/Jochen_Dress)\
**Post date:** [February 13, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/how-can-i-put-the-error-messages-generated-by-the-validation/53673/3 "2006-02-13T23:03:04Z")

</div>

> 1. Display the error messages in a side frame with it’s own scrollbar.

Ugh. Don’t do that. Scrolling subcontainers or side frames are rarely  
good UI decisions in HTML pages. If you have so many validation errors  
that the list is very long, consider placing the error messages adjacent  
to the fields instead of in a group.

> 1. Make a specific part of the message interactive, so a click of the  
> user on this part will take him right a way to the corresponding data  
> entry field.

Great idea. Use the Prototype javascript library to set focus on the  
field you get the error on. Make sure that the focus is very very  
obvious, since simply setting the cursor in the field isn’t easy to  
notice.

> 1. Change the color of the error message if the field entry was changed.

I think this is also a great idea. You’ll might want to submit your form  
when the user tabs away from each field, and update a div with the  
relevant errors. The trick is to make sure you _don’t_ display an error  
for a field the user hasn’t yet put a value into. That’s where it gets a  
little tricky, since you probably also want to insure certain fields  
aren’t empty.
