Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

Need regular expression to allow money.

How can I validate that a money amount has been entered?
Avatar of Guru Ji
Guru Ji
Flag of Canada image

You can try following regular expressions.

Example if you want to validate $2000 you can use

^\$\d+$  or if you want to validate $3000.00 then use

^\$\d+\.\d{2}$ or if you want to validate a negative then use

^\-\$\d+$

or a parenthesis then add ^\(\$\d+\)$ .

Though there is a library for regular expressions which you can use it to tailor with your needs.

Hope this helps
Avatar of HLRosenberger

ASKER

I don't need a negative, but I do want to used commas.
ASKER CERTIFIED SOLUTION
Avatar of Guru Ji
Guru Ji
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks.