KaushaL.NET

OnKeyPress event – event.keyCode and event.which (validating for numarics)

Posted by: Kaushal on: May 5, 2009

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….

Read More

Leave a Reply

You must be logged in to post a comment.

Victims

  • 38,888 Hits

Calendar

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Archives

KaushaL Parik (Microsoft MVP – ASP.NET)