3

I have a problem with login form field in Google Chrome browser. I have a form with input and I want to his value was empty after page reload (refresh). I used jQuery:

$(document).ready(function(){
    $("form input[name=user_login]").val("");
})

but in Chrome this solution doesn't work, and the field is set to remembered value.

Nikola
  • 14,888
  • 21
  • 101
  • 165
cichy380
  • 31
  • 1
  • 3

2 Answers2

5

If you set the attribute autocomplete=off, the content will never be stored.

Check the documentation:

user3226904
  • 51
  • 1
  • 4
  • I know this is a super old question, but this solution just worked for me and saved me a huge headache. After entering a coupon code, if someone went to a different page and then came back, the code would still be in the box but would not be recognized by my javascript (knockout) ... with autocomplete=off added to the input the code is gone when they return to the page. Thanks. – Phil Feb 11 '20 at 14:05
2

try this in html

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

refer this link for further information http://www.i18nguy.com/markup/metatags.html

------edit1-----

try this fiddle in chrome:

http://jsfiddle.net/nQ5sQ/1/

I have done by id .. but It works completely fine, that is no cache issue, and when your page is ready and you fired jQuery script on it, after that no caching is done. even your hypothesis seems to be incorrect. Please post same html and jquery code to debug

ManMohan Vyas
  • 4,004
  • 4
  • 27
  • 40
  • If still it dosent work, write your html and jquery code in fiddle or post it here. – ManMohan Vyas Sep 05 '12 at 09:44
  • Code is big :) but his simple version is on http://jsfiddle.net/nQ5sQ/4/ but to see the problem is not so easy. I don't know when the Chrome cache this data... – cichy380 Sep 05 '12 at 10:18
  • I reproduced your bug , this will happen only when user has saved his username and password.check this updated fiddle http://jsfiddle.net/nQ5sQ/10/ – ManMohan Vyas Sep 05 '12 at 10:45
  • also check this post: http://stackoverflow.com/questions/32369/disable-browser-save-password-functionality , for auto-complete off functionality – ManMohan Vyas Sep 05 '12 at 10:47