Ngx-mask: Validation with ng.dirty with mask field getting dirty

Created on 9 Nov 2017  路  7Comments  路  Source: JsDaddy/ngx-mask

I'm using anglar 5, in some input I'm using ngx-mask, it's doing some validations the inputs that contain the masks are getting dirty.

bug question

All 7 comments

@Glaycow Could you provide code example

Hello!

I have the same issue. The form is becoming dirty without receiving any input or interaction.

Even if you reset the form before testing the dirty property it will return true. Code example:

   // ...
   signupForm: FormGroup;
   // The person type controls the type of person being registered and toggles some inputs.
   personType: string = null;

   ngOnInit() {
     this.signupForm = new FormGroup({
       'name': new FormControl(),
       // ...
     });
   }

  // "Returns" to choose another person type (cpf / cnpj)
  onClickBack() {
    if (this.signupForm.dirty) {
      if (confirm("Are you sure you want to return? All data will be lost.")) {
        this.signupForm.reset();
        personType = null;
      }
    } else { 
      personType = null;
    }
  }

In the example above it's always asking for confirmation, even without any input added to the form.

As a temporary solution I'll be using the touched property.

Thank you for your attention!

@NepipenkoIgor I'm having the same issue too with both ReactiveForms and Template-Driven forms, here is a live demo https://stackblitz.com/edit/ngx-mask-issue-48

@vgildeev Thanks for the demo, i will investigate this

I'm experiencing this issue currently. On version 8.1.6. The form loads and the masked control is immediately dirty.

I'm also getting it in 8.1.7. I have to run a reset after the form loads.

39 / 5000
I also have this problem in 8.2.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renanBritz picture renanBritz  路  3Comments

Wisdomb33r picture Wisdomb33r  路  3Comments

cabbott65 picture cabbott65  路  4Comments

raisiqueira picture raisiqueira  路  3Comments

dimmal picture dimmal  路  3Comments