Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

Disable login form autocomplete

I'd like to disable autocomplete on my login forms. Is there any straightforward way of doing this?

Thanks

John

Tagged:

Answers

  • I used jquery and a simple hook in Wordpress. How can it be done in Vanilla?

    abhisek
  • 422422 Developer MVP

    Add autocomplete="off" to input element

    422 Real Estate Australia , now open Check it out

  • I'd rather not have to modify Vanilla core. I've figured out how to load jQuery from Google in my theme by hooking it into the head. How would I go about loading a custom script?

  • I was able to get my script to load using this piece of code:

    public function Base_Render_Before(&$Sender) { $AutocompleteOff = ' <script type="text/javascript"> $(document).ready(function() {$(\'input\').attr(\'autocomplete\',\'off\');}); </script>'; $Sender->Head->AddString($AutocompleteOff);

    That said, when the users clicks 'Sign In', the sign in form is dynamically loaded so I'm not sure if my piece of JS will work.

  • Come on folks! How would I do this without modifying the core?

  • there may be a better way. but this works.

    noauto.js

        jQuery(document).ready(function($) {
        $("input").livequery( function()
        $("#Form_Email").attr("autocomplete","off"));
        }); 
    

    create your own plugin and add something with this. or add something to your themehooks.

    public function Base_Render_Before($Sender) {
        $Sender->AddJsFile('/plugins/thenameofyourplugin/js/noauto.js');
    

    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    jcwebdev
  • Ok...got the script to load but it isn't adding this attribute to my inputs. Could it be that this is due to the login form being loaded by javascript after the page itself loads?

  • the livequery theoretically "lives on" even thought the form loads later.. do you have a link to your page and can you explain exactly what you did? if you want some help debugging.

    aside from the autocomplete issue itself.

    first see if the script works.

    cut and paste it in your console and run it and bring up the signin box.

    For a test I just modified the addmenu item plugin added the function and the js and it worked on my browser.


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

  • the script above will only add the attribute to #Form_Email"- which is what you requested not all inputs.

    why don't you turn off autocomplete in your browser. Maybe other users would like an autocomplete.


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    jcwebdev
  • I'm still stuck on this one. I need to disable autocomplete on all logins as my client has specifically requested it. The idea is that many of the site's users aren't particularly gifted technically and could well sign in and forget to sign out or leave their computer unattended.

    The sites are currently inaccessible to anyone outside my client's VLAN so I can't provide you with the URL to help with debugging.

    I can get an alert to display if I add it to the function but I cannot get the js function to add autocomplete=off to my inputs...where could I be going wrong? It must be the selector surely?

  • I no longer need this. I'm using jsConnect for single sign on and have removed all links to the default register/sign in pages.

    No users should be using them this way so there should be no data to autocomplete.

    Thanks for your help peregrine!

  • I did end up needing this, I created a custom plugin and disabled autocomplete on my login forms using this:

    class CustomJSPlugin extends Gdn_Plugin { public function Base_Render_Before(&$Sender)
    {
    $JavaScript = '

    $(document).ready(function() { $("#Form_User_SignIn input").attr("autocomplete","off"); });

    ';
    // Send it to the Header of the page
    $Sender->Head->AddString($JavaScript);
    } }

    Hope it helps someone!

Sign In or Register to comment.