Chrome Autofill covers Autocomplete for Google Maps API v3

后端 未结 21 1293
我在风中等你
我在风中等你 2021-02-01 00:57

I am using Google Maps Javascript v3 to setup autocomplete on an HTML input field like so:

http://imgur.com/Rm6X2FI.png - (w/out autofill)

The issue I\'m having

21条回答
  •  花落未央
    2021-02-01 01:45

    This was driving me totally crazy as well. Have the same issue. We use scripting to pull up field values for a user to select from and DO NOT want the browser's auto-whatever to mess this up. Chrome seems to be the bugger (latest version 42.0.2311.135 m), Firefox (FF) we can work with.

    So, we have to deal with the browser's autocomplete AND Chrome's autofill as well. If I add:

    at the top then it stops the autocomplete in FF and Chrome but not the AUTOFILL in Chrome. Changing 'off' to 'false' does nothing for either browser. Solved the FF issue but not Chrome as it shows the ugly AUTOFILL box over content.

    If you add autocomplete="off" to each of the fields individually then again, works in FF but for the input fields that have this attribute autocomplete in Chrome is off but the autofill still rears its ugly head.

    Now, the odd thing is that if you change the value in the individual input field from "off" to "false" then it seems to shake Chrome up and for the field you have this set to autocomplete="false" then you ONLY see the autocomplete values (if anything was entered in the field before) and all the other input fields show nothing! You can also set this value to no or xx or whatever and seems like Chrome barfs on the invalid value for autocomplete and the form reacts strangely. If you have 5 fields and set this for the third field then fields 1,2, 4 and 5 are blank but field 3 shows autocomplete.

    This is an example for you to copy and mess with (try moving the autocomplete attribute to different fields and see how it reacts) :

    
    
    
    
      Signup
    
    
    
      
        First name:
        
        
    Last name:
    Address:
    Phone number:
    E-mail:

    My solution to turn off both autocomplete and Chrome's autofill (you should be able to put the hidden input field at the top or bottom below the submit). Add this to the code:

    
    
    
    
      Signup
    
    
    
      

    First name:
    Last name:
    Address:
    Phone number:
    E-mail:

    Bottom line: Chrome does adhere to the autocomplete=off but the autofill of Chrome is the problem. Hope this helps.

提交回复
热议问题