Numeric value validation in php
This function return 1 if the argument passed to it is numeric only.
function onlynumber($value) {
$american = preg_match ("/^(-){0,1}([0-9]+)(,[0-9][0-9][0-9])*([.][0-9]){0,1}([0-9]*)$/" ,$value) == 1;
$world = preg_match ("/^(-){0,1}([0-9]+)(.[0-9][0-9][0-9])*([,][0-9]){0,1}([0-9]*)$/" ,$value) == 1;
return ($american or $world);
}
Monday, June 16, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment