validation on amount

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there,

I am using a form to let the user enter an amount.
This must be with zero OR with 2 decimals.
I'm using the comma for decimal seperator.
How can I check if the input is valid (ereg or preg_match?) and what is the  
exact statement I will have to use?

Please help me with this.
Thank you.


Re: validation on amount

If you're data will look like '2,10' and you're exploding on the comma
(i.e. array( 0=>2,1=>10) ), it's quicker and easier to use intval() or
is_numeric() on each of the parts. If that doesn't suffice, what
exactly are your constraints (since validation is very important)?


Best/easiest way is to split the two values (decimal and whole number)
into separate form values.

Site Timeline