ereg to validate decimal

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

ereg to validate decimal

Post by dardsemail »

Hi,

I am trying to write a little validation to ensure that numbers are entered to two decimal places.

Here's what I have - but it doesn't seem to be working:

Code: Select all

$validBidExpr = "^(ї0-9]{2,3,4,5,6,7,8,9}ї.]?)?ї0-9]{2}$"
I'm new to ereg, so I think I'm getting something wrong with the decimal.

Thanks!
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

try this

$pattern = '^[0-9]+\.[0-9]{2,}$';


1 or more numbers followed by a period
then 2 or more numbers

im kinda new myself so maybe someone can confirm my pattern
Post Reply