0
if ((key > 57 || key < 48) && key != 46) 
{
  if(window.event)
  {          
    window.event.returnValue=false;       // IE
  }          
  else
  {
   ???????           

  }
}      

Above code works for IE but it is not working for Firefox, Chrome and Safari. The return false is not working. Please guide me what I can write to return false in ???? area.

JJJ
  • 32,902
  • 20
  • 89
  • 102
Suga24
  • 55
  • 1
  • 7
  • 2
    It'd be nice to see a bigger context, but I assume `return false` doesn't work? – JJJ Jul 17 '12 at 07:15
  • http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false – Pavel Reznikov Jul 17 '12 at 07:16
  • 1
    @troolee that question is mostly about jQuery handlers, which act differently. If the OP was using jQuery he wouldn't be having these problems. – Alnitak Jul 17 '12 at 07:19

1 Answers1

0

What you do with the other browsers (and with IE9 in standards mode) is event.preventDefault() — probably. It depends a bit on how you're hooking up that event handler. But basically, IE's returnValue = false maps to preventDefault and IE's cancelBubble = true maps to stopPropagation.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875