update character counter of an input

1

I have a page where you can add fields in which clicking on "create new field" opens a modal with a input with a character counter and two buttons, being able to add as many fields as you want. However, when I create the first one, the remaining value of that counter (let's assume that it is 14 characters remaining) is the value that appears when I create a new field and open a new modal. It only updates, that is, it returns to the maximum number of characters allowed (20) when I press the input to write.

I've created these elements to do the update:

  element.focus(updateCounter).change(updateCounter);
  element.keyup(updateCounter).change(updateCounter);

Is there anything I can do to update as soon as modal opens, before doing focus no input ?

    
asked by anonymous 06.02.2017 / 16:25

0 answers