Hello,
Please help...

I wan't to check if somebody wrote float number in textfield (allowed only numbers and decimal digit).
If validation is not correct I'll wrote an error message.

I tried with:

if (ereg("([0-9]+)(.)([0-9]+)",$n,$match1) || ereg("([0-9]+)",$n,$match2)) {
if (($match1[0] != $n) && ($match2[0] != $n)) {
print "error message";
}
}

But it doesn't work for me because it allows to enter "ac" (only letters).

Help please.

    if (!is_numeric ($input)) {echo ''You must input numbers only';}

    you could use is_int(), and is_float() if you want to be more specific.

      How about:

      $x = @round($theVal, 2) or die("Not a float")

      Obviously is_float() is good too :p

        Write a Reply...