Page 1 of 1
Validating input as money value??
Posted: Wed Nov 24, 2004 5:41 am
by angelena
I have an input field for member input the money value,but i cant control the member either input the value as $12 or $12.12....
Let say if the field name is $money and i set that as a currency using
setlocale ....will that seems logic?
Thanks in advance ..

Posted: Wed Nov 24, 2004 7:46 am
by Crom
Use regular expressions. There are lots of them for money validation. Type in google 'regular expressions'.
Re: Validating input as money value??
Posted: Wed Nov 24, 2004 10:18 am
by pickle
angelena wrote:I have an input field for member input the money value,but i cant control the member either input the value as $12 or $12.12....
Actually, you could if you used Javascript - just do a check after each key pressed, with rules determining if it's a valid character.
Posted: Wed Nov 24, 2004 11:10 am
by phpScott
You should find some way of validating it on the server side agian but on the client side you can format the dollar value in your javascript by.
doesn't deal with $ or £ or € or any other money symbol but deals with number formating.
Posted: Wed Nov 24, 2004 11:35 am
by jason
Something to remember: Don't prevent the user from entering a $. I've seen too many sites that do something like:
Do not enter a $, or don't enter - when entering your credit card. You're the programmer. Simply remove these common characters, and then validate the result from there.
So, if someone enters ` $29.95 `, which has an extra space at the beginning and end, and a dollar sign, you can easily strip out the extra spaces and the dollar sign. Then, validate the result, which would be 29.95. That's much more intelligent than simply outputting "Error!"
Posted: Mon Nov 29, 2004 3:51 am
by angelena
Ohhh....thx for helping me...i able to get it done

Posted: Mon Nov 29, 2004 4:04 am
by angelena
Ohhh....thx for helping me...i able to get it done
