Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
This is the function isnum from maincore:

// Validate numeric input
function isnum($value, $decimal=false) {
   if (!is_array($value)) {
      if($decimal==true) return (preg_match("/^[0-9]+(\.{0,1})[0-9]*$/", $value));
      return (preg_match("/^[0-9]+$/", $value));
   } else {
      return false;

How can it be changed to accept negative numbers ass well?

3 replies


Just add a -?
See above
Perhaps for the second preg match as well.
Thanks, It is working now
Also in the second preg match?
author douwe_yntema
forumCode Snippet and functions - 8
replies4 posts
viewed735 times
activeLast updated on 1 year ago


SOLVED: isnum function located on maincore.....
Started by Elvenelf Elvenelf - 8 posts
Started by douwe_yntema douwe_yntema - 4 posts
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: Wanabo, douwe_yntema