By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

isNumeric function

P: 38
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
Share this Question
Share on Google+
3 Replies


epots9
Expert 100+
P: 1,351
this is a javascript question and not a php question.
Nov 18 '07 #2

pbmods
Expert 5K+
P: 5,821
Heya, Isaac.

What is an example of what you get if you alert(elem.value) instead of helperMsg?
Nov 18 '07 #3

gits
Expert Mod 5K+
P: 5,390
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.