Forum Moderators: coopster

Message Too Old, No Replies

Simple preg_match issue

         

lZakl

11:56 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



I know this is really simple, but I cannot get it to work. What I am trying to do is evaluate the value of $a and check to see that it contains only numeric chatacters [0-9] and allow a decimail '.' All other charatcers disallowed. Like I said, I know it is simple, but my logic is flawed somehow. (Don't tell my wife)

So in short I want someone to be able to enter

23.658 or 23 or .658

but NOT

#23.658 or @ or F OR (here is the kicker) 23.65.85 (two decimals)

Does this make sense? Any help I would be deeply grateful for!

-- Zak

coopster

12:42 am on Aug 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use either a regular expression or the is_numeric() function. Perhaps this recent thread on numeric validation [webmasterworld.com] will help.

lZakl

11:48 am on Aug 16, 2005 (gmt 0)

10+ Year Member



coopster,

That thread was most valuable! Thanks!

-- Zak