Welcome Guest, Not a member yet? Register   Sign In
Numeric Form Validation with NEGATIVE number...
#4

[eluser]wavefade[/eluser]
[quote author="gtech" date="1193894252"]Hello I looked at the documentation and can't find an option for validating signed integers.

if you look in libraries/validation.php the numeric function is a simple regular expression. you can simply change this to deal with negative and positive integers... e.g.

validation.php
Code:
...
  /**
  * Numeric
  *
  * @access    public
  * @param    int
  * @return    bool
  */    
  function numeric($str)
  {
    // original code..
    // return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
  
    return ( ! ereg("^\-*[0-9\.]+$", $str)) ? FALSE : TRUE;
  }
...

or add a new function.. maybe a feature request?[/quote]

Thanks a bunch! I used this little fix and it works great.


Messages In This Thread
Numeric Form Validation with NEGATIVE number... - by El Forum - 10-31-2007, 05:32 PM
Numeric Form Validation with NEGATIVE number... - by El Forum - 10-31-2007, 06:17 PM
Numeric Form Validation with NEGATIVE number... - by El Forum - 10-31-2007, 06:30 PM
Numeric Form Validation with NEGATIVE number... - by El Forum - 10-31-2007, 07:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB