Return to Snippet

Revision: 18018
at September 21, 2009 09:38 by chrisdpratt


Initial Code
if (
  (e.keyCode != 32) && // not spacebar
  (e.keyCode != 8) &&  // not backspace
  (e.keyCode != 46) && // not delete
  ((e.keyCode < 48) || (e.keyCode > 90)) // non-character
) return true;

Initial URL


Initial Description
The following script will allow only keys that effect actual text changes in input/textareas (character keys, spacebar, backspace and delete). Any other key type will tell whatever function is handling the event to return and not continue on. As a result, this should be place before the actual processing portion of the function.

Initial Title
Detecting Only Actual Text Changes onkeydown/onkeyup/onkeypress in JavaScript

Initial Tags


Initial Language
JavaScript