Skip to content

Is there a way to set an iMask field's value programmatically? #1039

Closed Answered by npearson72
npearson72 asked this question in Q&A
Discussion options

You must be logged in to vote

Turns out it's not an iMask issue at all. Figured it out like so:

  const value = ...;
  const inputEl = document.getElementById(...);


  inputEl.focus();

  await new Promise(resolve => {
    inputEl.value = value;

    inputEl.dispatchEvent(new Event('input', { bubbles: true }));

    resolve();
  });

  inputEl.dispatchEvent(new Event('keyup', { bubbles: true }));

  inputEl.blur();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by npearson72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant