How do I stop a browser prompting with past options

Browsers try to be helpful and remember that when you've filled in an input field named "email" before it's been with "ggg@something.somewhere.com" and they'll suggest that entry again. If you've used many different values for a named field, then they'll provide a drop down list of all the options you've ever used.

Mostly very useful, but not always. In my case I don't want a long list of previous options to pop up in a field because it's annoying the client. Also onchange behaves differently if you enter stuff into a field via the keyboard compared to selecting from previously entered values. In FF3 onChange isn't triggered if you select from previous values, but it is if you key the data in.

I've found a workaround, which is to give fields unique names, either by packing the input field name with some random chars, or something else that's unique, like the id of an order. But that is messy, horribly messy. There must be an easy way to do this. Maybe some param you can set on an input field, or some javascript trick.

Anyone have any ideas?

Thanks

John Small

Try adding :autocomplete => 'off' as in:

<%= form.text_field :email, :autocomplete => 'off' %>

and see if that doesn't do what you want.

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

Hi John,

I've found a workaround, which is to give fields unique names, either by packing the input field name with some random chars, or something else that's unique, like the id of an order. But that is messy, horribly messy. There must be an easy way to do this. Maybe some param you can set on an input field, or some javascript trick.

You're looking for the :autocomplete option. As in...

<%= text_field_tag 'first_name', nil, :autocomplete => "off" %>

HTH, Bill

Bill & rob

:autocomplete => "off" %>

I guessed that there had to be a simple way, though of course it's almost entirely undocumented. I looked it up and, wonder of wonders, it's one of the few good ideas Microsoft have brought to web programming, though it doesn't make up for IE6.

It appears that autocomplete="off" isnt' part of the web standards though most browsers except Opera will support it. Maybe it'll make it into HTML 5 or 6.

Thanks for the quick replies

John Small