-2
Good afternoon, you guys! I have a form and in it I have a select with the options (Phone and Mobile) and I also have an input for the user to fill in the number. I want that when the user selects the Phone option he trims the mask Mask="(00) 0000-0000" and when he selects the Cellular option appear the Mask="(00) 00000-0000". Can someone help us? Follow picture:
Follows the code:
<div class="form-group col-12 col-sm-4">
<label class="form-label" for="">Tipo <span class="text-danger">*</span> </label>
<select class="custom-select" formControlName="phoneType">
<option value=null selected=""></option>
<option value="1">Telefone</option>
<option value="2">Celular</option>
</select>
</div>
<div class="form-group col-12 col-sm-4 ">
<label class="form-label" for="phone">Número <span class="text-danger">*</span> </label>
<input mask="(00) 00000-0000" formControlName="phone" type="text" class="form-control" id="celular"placeholder="">
<div *ngIf="submitted && basicInfo.controls.phone.errors" class="text-danger">
<div *ngIf="submitted && basicInfo.controls.phone.errors">Campo obrigatório</div>
</div>
Take a look at my answer https://answall.com/questions/416081/como-aplica-mascara-din%C3%a2mica-em-input-no-angular/416242#416242
– Eduardo Vargas