estelle / input-masking

Framework agnostic accessible input masking library
MIT License
485 stars 96 forks source link

Initial Values Added to Masked Text Box Placeholder Overlayed #15

Open ZoomPicard opened 5 years ago

ZoomPicard commented 5 years ago

Loading in an initial value into a text box with the library enabled will mean the placeholder is drawn under the text.

I tried to call various events to fix this issue but found a small change to the code based worked by hiding the placeholder if there is already a value in the text box:

createShell : function (t) {
  ....

    mask.appendChild(emphasis);
    //Don't add placeholder if data already exists
    if (t.value.length == 0) {
        mask.appendChild(placeholder);
    }

   ....

  }
whitespacecode commented 5 years ago

I made a proper fix in this pull request: https://github.com/estelle/input-masking/pull/16

ZoomPicard commented 5 years ago

Thank you

Auer111 commented 4 years ago

I just masked initial text in the filed at activateMasking t.dispatchEvent(new Event("input", { bubbles: false, cancelable: false }));