views:

244

answers:

2

Hello, i need to validate currency field with formcheck plugin for mootools. It has number validation type, and number accepts regex to personalize validation.

I need sample to validate:

1.000,01   --> ok
1,000.02   --> not ok
1000,12    --> ok
1000.13    --> not ok
10.000     --> ok
100.00     --> not ok

and so on. Can you help me please?

thanks.

A: 

This will pass all your tests:

^(\d|\.\d{3}|,\d+$)*$

If you want to require at least one digit, use:

^\d(\d|\.\d{3}|,\d+$)*$
Max Shawabkeh
+1  A: 

^\d+(?:\.\d\d\d)*(,\d\d)?$

I'm assuming . is your thousands separator, , is the decimal separator, and the comma must always be followed by two digits if it's present.

Alan Moore