473,748 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Analyse this code and temme why it is used so

haridhasekar
8 New Member
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 1416
larztheloser
86 New Member
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
haridhasekar
8 New Member
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
larztheloser
86 New Member
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
haridhasekar
8 New Member
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
3982
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. Please let me know :)
35
3679
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 ********** ColumnA ColumnB ColumnC ColumnD ColumnE
2
1979
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. Is there a Browser extending for Firefox oder Mozilla?
3
5269
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 access. Also DBA support starts after our jobs have completed. (1) Is there any command that I could use from command line to find out the process taking up maximum of the database resources ? (2) Can the database snapshot be used for this purpose ?...
3
12180
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 message: WARNING: out of shared memory ERROR: out of shared memory HINT: You may need to increase max_locks_per_transaction.
7
2228
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 times. what is the problem here..?????????????????? #include "stdafx.h" #include<iostream>
5
1336
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 source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * 1. Redistributions of source code must retain the above copyright
8
2093
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 **sPtr = { s+3, s+2, s+1, s };
0
1608
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. Ich hab bisher nur die sündhaft teuren Produkte von DevPartner gefunden. Gibt es billigere oder gar kostenlose/OpenSource Tools, mit denen ich die Aufgabe lösen könnte? Habt vielen Dank
4
2116
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; 2- the total number of lines (traces) foreach adress; 3-the total numbers of traces for each service; 4-the total number of connections pop, ssh and imap; 5- the list of addresses that made a ssh connection and how many for each 6- list of...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9552
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9249
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8245
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.