I'm using WTForms to display and validate form input. I use a DecimalField
for a money amount input, which works fine when inserting a value with a dot as a decimal separator. Since this website will be used in continental Europe however, I also want to allow a comma as a decimal separator. This means that both "2.5" and "2,5" should result in a value meaning "two and a half".
When I input a value with a comma, I get an error saying 'Not a valid decimal value'
. How can I accept both dots and commas as decimal separators with WTForms?
I know I can use Babel to use locale-based number formatting, but I don't want that. I specifically want to accept both a dot and a comma as separator values.