mercredi 7 octobre 2015

Adding a space after 4 chars in an input

I thought that this would add a space after each 4 chars, but instead, after the fourth digit the input is set to ''. Why?

keyUp: function(e) {
    if (e.target.value.length === 4) {
      var value = e.target.value + ' ';
      e.target.value = value;
    }
    else if (e.target.value.length === 9) {
      e.target.value += ' ';
    }
    else if (e.target.value.length === 14) {
      e.target.value += ' ';
    }
  },

Aucun commentaire:

Enregistrer un commentaire