24

Is there anyway to prevent the browser from displaying previously inputted values for a field on press of the down key?

If this is not possible, another problem of mine is on press of the down key, the list of previously inputted values will be shown and on press of the TAB key, the currently highlighted value on the list will be chosen and will be set as the value of the field. I do not want this, I just want the focus to be passed to the next input element w/o choosing any values.

Are there any ways to override the browser behavior? A solution in play javascript is preferred though jQuery solutions are fine as well. Thanks!

Ram
  • 1,016
  • 4
  • 15
  • 25
  • possible duplicate of [How do you disable browser Autocomplete on web form field / input tag?](http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag) – RichieHindle Jul 16 '13 at 07:11

3 Answers3

52

Just add the autocomplete attribute

<input type="text" autocomplete="off" />
adeneo
  • 312,895
  • 29
  • 395
  • 388
4

You can disable autocomplete by adding autocomplete="off" onto your input tags. MDN Reference

Example

<input type="text" name="email" value="" autocomplete="off" />

See this Stack Overflow post for browser compatibility.

Community
  • 1
  • 1
CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176
0

html code

<input type="text" autocomplete="off" id="password-field" class="form-control"  name="multi_user_pin" placeholder="Type your PIN here"/>
jquery code
$('#password-field').on('input keydown',function(e) { 
            if(e.keyCode == 8 && $(this).val().length==1) {
                $(this).attr('type', 'text');
                $(this).val('');
             }
            else{
                if ($(this).val() !== '') {
                    $(this).attr('type', 'password');
                } else {
                    $(this).attr('type', 'text');
                }
             }

        });

This code works fine for password field to prevent to remember its history with all browsers