【问题标题】:Chrome Autofill triggering separately for billing and contact informationChrome 自动填充分别触发计费和联系信息
【发布时间】:2021-10-18 11:10:24
【问题描述】:

自动填充功能会分别针对帐单和联系信息触发。

例如,当我单击以下 4 个输入填充中的任何一个时,它会为它们提供自动填充 => 名字、姓氏、电话号码和电子邮件。当我单击以下 4 个中的任何一个时,它会同时触发它们的自动填充 => 帐单地址、帐单邮政编码、帐单国家/地区、帐单城市。

自动填充对两个组中的每一个都适用,但我希望它是一个可以通过选择 8 个输入字段中的任何一个来自动填充的组。

代码示例(我将 Angular 8 与 Material design 组件一起使用,但我认为这不应该让人分心,因为我认为这是一个 HTML 问题):

<form method="post" id="paymentForm" [formGroup]="formGroup" (ngSubmit)="onSubmit(formGroup.value)" class="form" >

    <div class="customer-info">
        <div class="customer-info-personal">
            <div>
                <mat-form-field class="form-element">
                    <input name="fname" matInput placeholder="Ime" formControlName="firstName" autocomplete="given-name" form="paymentForm">
                    <mat-error
                        *ngIf="!formGroup.controls['firstName'].valid && formGroup.controls['firstName'].touched">
                    </mat-error>
                </mat-form-field>
                <mat-form-field class="form-element">
                    <input name="lname" matInput placeholder="Prezime" formControlName="lastName" autocomplete="family-name" form="paymentForm">
                    <mat-error *ngIf="!formGroup.controls['lastName'].valid && formGroup.controls['lastName'].touched">
                    </mat-error>
                </mat-form-field>
                
                <mat-form-field class="form-element">
                    <input name="bill-address" matInput placeholder="Adresa" formControlName="billingAddress" autocomplete="billing street-address" form="paymentForm">
                    <mat-error *ngIf="!formGroup.controls['billingAddress'].valid && formGroup.controls['billingAddress'].touched">
                    </mat-error>
                </mat-form-field>

                <mat-form-field class="form-element">
                    <input name="bill-city" matInput placeholder="Grad" formControlName="billingCity" autocomplete="billing address-level2" form="paymentForm">
                    <mat-error *ngIf="!formGroup.controls['billingCity'].valid && formGroup.controls['billingCity'].touched">
                    </mat-error>
                </mat-form-field>
            </div>
            <div>
                <mat-form-field class="form-element">
                    <input name="bill-zip" matInput placeholder="Poštanski broj" formControlName="billingPostalNumber" autocomplete="billing postal-code" form="paymentForm">
                    <mat-error
                        *ngIf="!formGroup.controls['billingPostalNumber'].valid && formGroup.controls['billingPostalNumber'].touched">
                    </mat-error>
                </mat-form-field>
                <mat-form-field class="form-element">
                    <input name="bill-country" matInput placeholder="Država" formControlName="billingCountry" autocomplete="billing country" form="paymentForm">
                    <mat-error *ngIf="!formGroup.controls['billingCountry'].valid && formGroup.controls['billingCountry'].touched">
                    </mat-error>
                </mat-form-field>
                <mat-form-field class="form-element">
                    <input name="email" matInput placeholder="e-mail" formControlName="email" autocomplete="email" type="email" form="paymentForm">
                    <mat-error *ngIf="!formGroup.controls['email'].valid && formGroup.controls['email'].touched">
                    </mat-error>
                </mat-form-field>
                <mat-form-field class="form-element">
                    <input name="phone" matInput placeholder="Broj telefona" formControlName="phoneNumber" autocomplete="tel" type="tel" form="paymentForm">
                    <mat-error
                        *ngIf="!formGroup.controls['phoneNumber'].valid && formGroup.controls['phoneNumber'].touched">
                    </mat-error>
                </mat-form-field>
            </div>

        </div>
        <div class="buttons-element">
            <div class="pay-button-element">
                <button mat-raised-button color="primary" type="submit" class="button"
                    [disabled]="!formGroup.valid">Plati</button>
            </div>
            <div class="cancel-button-element">
                <button mat-button color="secondary" type="submit" class="button">Odustani</button>
            </div>
        </div>
    </div>
</form> ```

【问题讨论】:

    标签: html forms google-chrome autocomplete autofill


    【解决方案1】:

    通过从 autocomplete 值中删除单词 billing 和从 name 值中删除 bill- 来修复它。

    例如

    autocomplete="billing postal-code" name="zip"之前

    autocomplete="postal-code" name="zip"之前

    事实证明,仅更改 autocomplete 字段就足够了。

    【讨论】:

      猜你喜欢
      • 2015-11-24
      • 2014-03-28
      • 2017-02-17
      • 1970-01-01
      • 2016-01-15
      • 2016-10-02
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多