Skip to content

When assign value not fire change event #20

@RicardoBer

Description

@RicardoBer

If you want, for example, capture onchange event for force only numbers, you can't.

In the same manner you can't catch keypress or so.

Any way, I propouse to add at least onchange event. For this I propouse:

Keyboard.prototype.printChar = function(char) {
  var selStart = this.$current_input[0].selectionStart;
  var selEnd = this.$current_input[0].selectionEnd;
  var textAreaStr = this.$current_input.val();
  var value = textAreaStr.substring(0, selStart) + char + textAreaStr.substring(selEnd);

  this.$current_input.val(value).focus();
++++  this.$current_input.trigger('change'); //ADD THIS FOR FIRE CHANGE EVENT 2018-11
  this.$current_input[0].selectionStart = selStart+1, this.$current_input[0].selectionEnd = selStart+1;

};

Now you can add this:

onchange="this.value=this.value.replace(/[^\d]/,'');"

to any input and force only integer numbers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions