setting autocomplete="off" in login form

200 views
Skip to first unread message

Fred

unread,
Oct 19, 2009, 3:18:35 PM10/19/09
to web2py-users
Given the security policy where I work I've been asked to try to
disable the web browser feature that saves login passwords. It looks
like setting the non-standard 'autocomplete' attribute to "off" for
the login FORM element can do that for many browsers. I'm trying to
figure out how to do that in web2py.

My best attempt so far is to add the following to views/default/
user.html just before the "{{=form}}" line:

{{ form.attributes['_autocomplete'] = "off" }}

Is that a valid way to do it? It seems to work the way I want for
Firefox at least but I'm concerned that it might not be forward-
compatible as web2py evolves.

Thadeus Burgess

unread,
Oct 19, 2009, 3:24:22 PM10/19/09
to web...@googlegroups.com
If you are using FORM, SQLFORM, or SQLFORM.factory, you can just pass the attribute to the instance.

form = SQLFORM(db.mytable, _autocomplete="off")
form = SQLFORM.factory(Field(...), _autocomplete="off")
form = FORM(INPUT(...), _autocomplete="off")

web2py will always be backwards compatible.

-Thadeus

mdipierro

unread,
Oct 19, 2009, 3:25:41 PM10/19/09
to web2py-users
I have not tried but perhaps this:

<script>
jQuery(document).ready(function(){jQuery('input').attr
('autocomplete','off');});
<script>
Reply all
Reply to author
Forward
0 new messages