首页 > 解决方案 > Chrome 自动填充分别触发计费和联系信息

问题描述

自动填充将分别触发计费和联系信息。

例如,当我单击以下 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> ```

标签: htmlformsgoogle-chromeautocompleteautofill

解决方案


billing通过从自动完成值和bill-名称中删除单词来修复它。

例如

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

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

事实证明,仅更改自动完成字段就足够了。


推荐阅读