number format isn't localized #437
This commit is contained in:
parent
a16de19ee7
commit
4de9b614dc
2 changed files with 17 additions and 2 deletions
|
|
@ -459,6 +459,11 @@ class Utils
|
|||
|
||||
public static function parseFloat($value)
|
||||
{
|
||||
// check for comma as decimal separator
|
||||
if (preg_match('/,[\d]{1,2}$/', $value)) {
|
||||
$value = str_replace(',', '.', $value);
|
||||
}
|
||||
|
||||
$value = preg_replace('/[^0-9\.\-]/', '', $value);
|
||||
|
||||
return floatval($value);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,18 @@
|
|||
@endif
|
||||
|
||||
NINJA.parseFloat = function(str) {
|
||||
if (!str) return '';
|
||||
str = (str+'').replace(/[^0-9\.\-]/g, '');
|
||||
if (! str) {
|
||||
return '';
|
||||
} else {
|
||||
str = str + '';
|
||||
}
|
||||
|
||||
// check for comma as decimal separator
|
||||
if (str.match(/,[\d]{1,2}$/)) {
|
||||
str = str.replace(',', '.');
|
||||
}
|
||||
|
||||
str = str.replace(/[^0-9\.\-]/g, '');
|
||||
|
||||
return window.parseFloat(str);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue