Validate comma as numeric in Editor
Validate comma as numeric in Editor
Greetings,
I have searched for a solution to a problem i'm having regarding input in Editor.
I want to validate a field as numeric, but want to allow comma as a decimal separator instead the dot that is by default.
From the documentation i found this :
https://editor.datatables.net/manual/php/validation#Numbers
I performed the following code to try, but the numeric validation does not accept the comma as valid :
Field::inst( 'expenses.expenseValue' )
->validator( 'Validate::notEmpty', array('message'=> 'É necessário colocar um valor numérico!'))
->validator( 'Validate::numeric', array(
'decimal'=> ',',
'message'=> 'É necessário colocar um valor numérico!'
)),
What am i doing wrong ? Does anyone has a working example so i can compare what is my mistake ?
Best Regards,
Pedro
Answers
Hi Pedro,
You need to use a set formatter as well to convert it to a decimal form the database will understand:
Allan
Hi Allan, do there is Javascript counterpart for the set formatter?
Hi @williamay53 ,
For the backend, you can use JS if you're using Node - see here.
Cheers,
Colin