Question

I'm trying to validate some numbers on my asp.net mvc5 application with globalize.js plugin for jquery...

When i enter number with , as decimal separator, everything works fine as it should be. When i enter it with ., number pass validation but this is wrong, and error should be thrown. I checked what's happening in jquery and found that line used to check number

var val = Globalize.parseFloat(value);

is returning wrong value. When i pass 1,25, result is 1.25. When i pass 1.25, return value is 125, instead of error...

I have declared

  Globalize.culture('sr-Latn-RS');

in my javascript and

<globalization culture="sr-Latn-RS" uiCulture="sr-Latn-RS" />

in web.config.

Is there any workaround for this?

Was it helpful?

Solution

After few days of exploring a problem, i finally found it in a "Handle Groups" part of ParseFloat function of jquery.globalize plugin.

integer = integer.split( groupSep ).join( "" );

line should be replaced with

integer = integer.split(groupSep).join(nf["."]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top