473,408 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Analyse this code and temme why it is used so

haridhasekar
hi all,
pls analyse the code .. temme why it is used so ... is there any alternate method to validate whether it is a numeric....if so temme.....

Expand|Select|Wrap|Line Numbers
  1. function isnumeric(e,obj)
  2. {
  3.     var keynum;
  4.     if(window.event)     
  5.                 {
  6.     keynum=e.keyCode;
  7.     }
  8.     else if(e.which)     
  9.                 {
  10.     keynum=e.which;
  11.     }
  12.  
  13.     return((keynum >= 48 && keynum <= 57) ||keynum==189|| keynum==46 ||(keynum>=32 && keynum<=40) || keynum == 8 || keynum==9 ||(keynum >=96 && keynum <=105));
  14. }
Feb 27 '10 #1
4 1402
Well, it is used together with some sort of event handler, such as onkeydown. Different browsers pass different values to event functions so the next few lines have a way of getting the pressed key code for 2 different browsers. Finally the big if checks whether this key code is a number key on the keyboard. So many numbers must be checked cause there are several keyboard configurations.

So far as I know this is the best and most efficient way to do this, and I can't think of another though I bet there is a roundabout way somehow...
Feb 27 '10 #2
Can you please explain in detail the words 'Different browsers pass different values to event functions '... whats the need of using keycode....
Feb 27 '10 #3
Well, rather than pass a string of the key hit to the function, browsers pass the scancode of the key. This is more suitable for international keyboards. However, some pass it as the event parameter of the first argument of the function, and some as the which parameter (the second argument is not used by the function). I think it is IE that uses e.event.
Feb 27 '10 #4
Thanks frnd... i got it clearly.... thanks for ur reply....

http://www.quirksmode.org/js/introevents.html
Mar 1 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Johan Holst Nielsen | last post by:
Hi, Is there any Python packages to analyse or get some information out of an PDF document... Like where the text are placed - what text are placed - fonts, embedded PDFs/fonts/images etc. ...
35
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 **********...
2
by: Patrick Fischer | last post by:
Hello Hello I looks for a possibility to analyse html while browsing. Like a DOM Inspector. While the page is loading the analyser check the page, make a DOM tree and I can get the DOM tree. ...
3
by: sac | last post by:
I am using DB2 v8.1 on UNIX. At times the database shows extremely poor performance. I do not have dba/admin rights nor do I have the web based client for db2 v8.1. I have only command line...
3
by: Phil Endecott | last post by:
Dear PostgreSQL experts, This is with version 7.4.2. My database has grown a bit recently, mostly in number of tables but also their size, and I started to see ANALYSE failing with this...
7
by: alankrit | last post by:
Helo This is a code for Radix sort. n it is giving a run-time Error : "Run-Time Check Failure #2 - Stack around the variable 'count' was corrupted." I have cross checked this code a millions of...
5
by: Vusi | last post by:
/* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ /* * Copyright (c) 2003, 2004 David Young. All rights reserved. * * This code was written by David Young. * * Redistribution and use in...
8
by: novice | last post by:
Hi geeks, Can any body explain me how to analyse int the pollowing code This is the question I was asked in the interview... char *s ={ "hello", "basic", "world", "program"}; char...
0
by: =?ISO-8859-1?Q?Konrad_M=FChler?= | last post by:
Hallo, ich bin auf der Suche nach einem Tool, mit dem ich unter Visual Studio 7 oder 8 eine Performance Analyse auf meinem Code durchführen kann, um zu ermitteln, wo wieviel Zeit verloren geht....
4
by: finelady | last post by:
Hello, I am new on perl and want to do one script who will ask for the name of the log file to analyse and will give the statictics : 1- the covered period of the log (start-end) by date and hours;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.