validation on amount

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stefan van Roosmalen

    validation on amount

    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.

    Stefan.


  • bobzimuta

    #2
    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)?

    2,00
    0,00
    100000000000000 000000000000000 0,00
    9,99

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

    Comment

    Working...