OnKeyPress event – event.keyCode and event.which (validating for numarics)
May 5, 2009 Leave a comment
I am trying to validate textbox for numeric entry, while I added this code to accomplish in page_load event:
textbox.Attributes.Add(“onkeypress”, “return (window.event.keyCode == 45 || window.event.keyCode == 13 || window.event.keyCode == 8 || window.event.keyCode == 9 || window.event.keyCode == 189 || window.event.keyCode == 109 || (window.event.keyCode >= 48 && window.event.keyCode <= 58) )”);
It worked fine in IE7 and IE8, but it didnt work for FF though. A bit googling gave me conclusion that….
