469,277 Members | 2,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

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 2513
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

Post your reply

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

Similar topics

8 posts views Thread by eje | last post: by
4 posts views Thread by Eugene Anthony | last post: by
14 posts views Thread by Kenny | last post: by
8 posts views Thread by John Bowman | last post: by
10 posts views Thread by michele | last post: by
7 posts views Thread by Nathan Truhan | last post: by
9 posts views Thread by Kimelia Schiles | last post: by
12 posts views Thread by sck10 | last post: by
9 posts views Thread by =?Utf-8?B?VG9ueQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.