hyo29 hyo29 - 1 year ago 162
Javascript Question

Overtype mode with jquery

How could I make my input field act as if the keyboard is in overtype mode?

I tried to trigger the keypress event with the delete button in keycode when the user enter a value but nothing happen.

Answer Source

Something like:

<input onkeydown="this.oldSize = this.value.length;" 
  onkeypress="var n = this; setTimeout(function() {
      if(n.value.length > n.oldSize) {
        var s = n.selectionStart;
        n.value = n.value.substr(0, s) + n.value.substr(s + 1);
        n.selectionStart = n.selectionEnd = s;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download