Ok forget it, someone suggest to me:
if ((string)((float)$amount) == $amount && (float)$amount > 0) {
  print "ok";
}else print "error";

and it works perfectly!
py

----- Original Message -----
From: py <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 19, 2001 11:14 AM
Subject: Re: [PHP] Re: Simple validation problem


> I wonder how that can be enough, if you consider the following form,
> you can enter "45-98" and it will print ok !!
>
> Since all http is coming as a string, I beleive the only way is to test
for
> invalid
> characters as anything except  [0-9] and the dot. (wich is my problem
> because I do not really know how)
> I event try with casting amount like this:
> $amount = (float)($amount);
> It does not work, I can still input "12r5" for exemple.
>
> py
>
> if( $amount >0 ){
>   print "ok";
> }else print "smaller than 0: error";
>
> if( is_float( $amount )){
>   print "ok";
> }else print "not a float: error";
> ?>
> <FORM ACTION="<? print $PHP_SELF ?>" METHOD="post">
> <INPUT TYPE="Text" NAME="amount" SIZE="4">
> <INPUT TYPE="Submit" NAME="Submit" VALUE="Submit">
> </FORM>
>
> ----- Original Message -----
> From: CC Zona <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 18, 2001 10:15 PM
> Subject: [PHP] Re: Simple validation problem
>
>
> > In article <00ef01c10fa5$fd20f2e0$e064fea9@py>, [EMAIL PROTECTED] (Py)
> > wrote:
> >
> > > I am trying to make shure the amount is positive
> >
> > if($amount >0)
> >    {...}
> >
> > > and is a float
> >
> > if(is_float($amount))
> >    {...}
> >
> > --
> > CC
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to