473,379 Members | 1,222 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,379 software developers and data experts.

isNumeric function

i found this code in a website and it works but the problem is when i press TAB and BACKSPACE it also give me the error message
Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2. function isNumeric(elem, helperMsg){
  3.     var numericExpression = /^[0-9]+$/;
  4.  
  5.     if(elem.value.match(numericExpression)){
  6.         return true;
  7.     }else{
  8.         alert(helperMsg);
  9.         elem.focus();
  10.         return false;
  11.     }
  12. }
  13. </script>
  14.  
does any body have any idea what can i do or what additional things could be added to this code

thnaks
Nov 18 '07 #1
3 2694
epots9
1,351 Expert 1GB
this is a javascript question and not a php question.
Nov 18 '07 #2
pbmods
5,821 Expert 4TB
Heya, Isaac.

What is an example of what you get if you alert(elem.value) instead of helperMsg?
Nov 18 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

i assume the the function is called 'onkeypress'-event? so in that case the keypress-handler has to be adapted ... could you post the code for it?

kind regards
Nov 19 '07 #4

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

Similar topics

8
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the...
4
by: Eugene Anthony | last post by:
I have received the following feedback for the two functions bellow: "The ISNUMERIC test is WORTHLESS for checking for an INT value, because ISNUMERIC will happily accept DOUBLE values, such as...
14
by: Kenny | last post by:
Hello, I would like to know if the function IsNumeric requires a header like #include <iostream> to be functionnal thanks ken
8
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML...
10
by: michele | last post by:
I have a problem with VB.Net and IsNumeric() function because it always returns FALSE even the string can be a number. There is another strange thing, the same program (it is a test) runs good on...
8
by: Dave | last post by:
I'm trying to import Microsoft.VisualBasic to use the IsNumeric function in my C# code but all I see is: Microsoft.VisualBasic.VBCodeProvider while using Intellisense... From samples shouldn't...
7
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a...
9
by: Kimelia Schiles | last post by:
Hi, I am new to C#, and I am a VB programmer. I would like to know whether there is any function in C# that can is similar to IsNumeric in VB?
12
by: sck10 | last post by:
Hello, I am trying to determine if a value is NOT numeric in C#. How do you test for "Not IsNumeric"? protected void fvFunding_ItemInserting_Validate(object sender, FormViewInsertEventArgs...
9
by: =?Utf-8?B?VG9ueQ==?= | last post by:
Can anybody tell why IsNumeric("5-") is true?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.