RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.4k stars 2.17k forks source link

clearIncomplete: Incomplete value stays in form value & mask disappears on submit. #2257

Open akvaliya opened 4 years ago

akvaliya commented 4 years ago

With clearIncomplete when mask is incomplete input gets clear but value in form stays like 12:4M with HH:MM mask.

Start typing value & keep input incomplete. Input will be cleared but value in form will stays with mask. Also on click of submit form mask disappears even if clearMaskOnLostFocus: false. Click on button & test.

RobinHerbots commented 4 years ago

That is because angular probably acts on the input event.

  ngAfterViewInit() {
    this.zone.runOutsideAngular(() => {
      Inputmask("datetime", { inputFormat: "HH:MM", clearIncomplete: true, clearMaskOnLostFocus: false,
      onincomplete: function(){
        Inputmask.dependencyLib(this).trigger("input");
      } }).mask(document.querySelectorAll("input[data-inputmask]"));
    });
akvaliya commented 4 years ago

@RobinHerbots

That is because angular probably acts on the input event.

  ngAfterViewInit() {
    this.zone.runOutsideAngular(() => {
      Inputmask("datetime", { inputFormat: "HH:MM", clearIncomplete: true, clearMaskOnLostFocus: false,
      onincomplete: function(){
        Inputmask.dependencyLib(this).trigger("input");
      } }).mask(document.querySelectorAll("input[data-inputmask]"));
    });

This resolves issue of incomplete value but masking still disappears on click of submit button.