开发者

mootools formcheck : regex for number validation

i need to validate currency field with formcheck plugin for mootools. It has number validation typ开发者_JAVA技巧e, 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.


^\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.


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+$)*$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜