Is event digit - Node.js DOM

Node.js examples for DOM:Event

Description

Is event digit

Demo Code

function IsDigit( e )
{
  e = e || event ;// w  w  w  .  java 2 s .c  o  m
  var iCode = ( e.keyCode || e.charCode ) ;

  event.returnValue =
    (
      ( iCode >= 48 && iCode <= 57 )    // Numbers
      || (iCode >= 37 && iCode <= 40)    // Arrows
      || iCode == 8            // Backspace
      || iCode == 46            // Delete
    ) ;

  return event.returnValue ;
}

Related Tutorials