V. Alex Brennen wrote :111
Here`s one which will allow decimal numbers:
function only_decimal_digits($string)
{
if(ereg_replace("[^0-9.]","",$string)==$string) return 1;
else return 0;
}
function only_comma_delimited_digits($string)
{
if(ereg_replace("[^0-9,]","",$string)==$string) return 1;
else return 0;
}
function only_comma_delimited_decimal_digits($string)
{
if(ereg_replace("[^0-9.,]","",$string)==$string) return 1;
else return 0;
}
Ok, you get the idea. ereg_replace returns a string - the
if statement compares the string that the ereg_replace call
returns. If they match, a 1 or TRUE is returned. If they
do not match a 0 or FALSE is returned. The syntax of the
ereg_replace call is [(range)], the ^ inverts it (not). So
the ereg_replace calls say "Replace anything that is not in
the range [0-9.] (or what ever you place in that range)".
Then the if statment checks to see if ereg_replace did
replace anything.