# Adding validation to text fields with autocomplete and to select fields

**URL:** <https://www.ruby-forum.com/t/adding-validation-to-text-fields-with-autocomplete-and-to-select-fields/128716>\
**Category:** Rails\
**Created:** [February 10, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/adding-validation-to-text-fields-with-autocomplete-and-to-select-fields/128716 "2008-02-10T22:38:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CSSSSssio\_Marques](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/48db29/32.png) [@CSSSSssio\_Marques](https://www.ruby-forum.com/u/CSSSSssio_Marques)\
**Post date:** [February 10, 2008, 10:38pm UTC](https://www.ruby-forum.com/t/adding-validation-to-text-fields-with-autocomplete-and-to-select-fields/128716/1 "2008-02-10T22:38:29Z")

</div>

Hello everybody,

I’m just learning rails right now and for simple CRUD operations I’m  
using  
scaffold to generate some code. I’m using Rails 1.2.6.  
I’ve changed some of the fields to use an autocomplete feature and  
validation using validate\_presence\_of is not working on these fields.  
The  
problem is that this fields are related to stuff inside a different  
model,  
like:

I have two tables, one called artist and the other called album. Album  
has a  
foreign key to Artist. So in the \_form.rhtml for the album i have a  
field  
with autocompletion for the name of the artist. In the album controller  
I  
make a search for the artist with the received name and associate it to  
the  
newly created instante of Album. But if the user sends the form with the  
artist\_name empty, I don’t know how to use the validation helpers…

This isn’t working for select fields nether. Putting it simple, it just  
works for ordinary text fields.

Anybody?

Thank you very much!

CÃ¡ssio Marques
