Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome assigns a text field as a password field

I have a basic text field but Google Chrome assigns it as a password field.

<form [formGroup]="formBuilder">

  <p>
    <mat-form-field appearance="fill">
      <mat-label>Title</mat-label>
      <input matInput placeholder="Type a title" formControlName="title">
    </mat-form-field>
  </p>

  <p>
    <mat-form-field appearance="fill">
      <mat-label>Description</mat-label>
      <textarea matInput></textarea>
    </mat-form-field>
  </p>

  <p>
    <mat-form-field appearance="fill">
      <mat-label>Label of a detail</mat-label>
      <input matInput type="text"> <!-- THE PROBLEM -->
    </mat-form-field>

    <mat-form-field appearance="fill">
      <mat-label>Description of a detail</mat-label>
      <input matInput type="text">
    </mat-form-field>
  </p>

</form>

This is what it looks like if I click on that input field:

enter image description here

I have tried the same code on StackBlitz but there it looks good and I don't see the problem there.

I am running that page on localhost:4200. How comes this field is a password field??

like image 427
xRay Avatar asked Sep 16 '25 08:09

xRay


1 Answers

My problem was solved when I added IDs to the input fields.

<mat-form-field appearance="fill">
  <mat-label>Label of a detail</mat-label>
  <input id="detail-label" matInput type="text">
</mat-form-field>

<mat-form-field appearance="fill">
  <mat-label>Description of a detail</mat-label>
  <input id="detail-description" matInput type="text">
</mat-form-field>
like image 54
xRay Avatar answered Sep 17 '25 22:09

xRay