Disabling Safari autofill on usernames and passwords

后端 未结 17 1757
萌比男神i
萌比男神i 2020-11-29 03:52

You might already know, that Safari has a nasty autofill bug where it fills email, username and password fields no matter if you set autocomplete=\"off\" or not

17条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 04:27

    For me, this problem was very sharp. But only about password autofill.

    Safari generates it's 'strong' password into a sign-in form. Not a sign-up form. Only the user's password will work in sign-in form, not generated. Obvious.

    I made a few tries to disable it with advice from here. But without results.

    BTW. It was easy to fix with angular binding. So. This code will work 4 you only in case of using Angular2+ in the web layer.

    
      Enter your password
      
    
    

    Attribute [type] use one side binding with "[", "]". And automatically set value by the condition "(condition) ? option1: option2". If no symbols in the input - then the type is 'text'.

    And not very 'clever' Safari browser doesn't perform autofill. So. Goal reached. Autofill disabled.

    After more than 1 symbol in the input field. Type changes to 'password' very fast. And the user has no idea about something that happened. The type of the field is 'password'.

    Also, it works with (keypressed) Event. Or using [(ngModel)]="pwd" instead of #pwd. And access by reactive forms.

    But the basic thing that solved the problem for my cases - angular binding.

提交回复
热议问题