开发者

mootools formcheck : regex for number validation

开发者 https://www.devze.com 2022-12-20 11:16 出处:网络
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 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

精彩评论

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