RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

is it possible group seperator based on culture. for the example #1861

Open ponmani opened 6 years ago

ponmani commented 6 years ago

@RobinHerbots is it possible group seperator based on culture. for the example

jQuery.preferCulture("en-IN"); var price = jQuery.format("3867567659.8880", "n4");

"3,86,75,67,659.8880"

ponmani commented 6 years ago

We need very urgent. If you have any kind of solutions. Please let me know.

RobinHerbots commented 6 years ago

@ponmani,

Sorry but I will not implement this very soon, as there already so many issues waiting.

Anyway, if you go for implementing it yourself. What need to be done is provide some mapping between the culture and the needed groupSeparator and radixPoint. (jquery.globalize does that already) You can define an option like culture in the numeric alias and if this is defined override the radixPoint and groupSeparator options. Within the numeric alias you have the mask function. When you add this in in front of the existing code it should work.

https://github.com/globalizejs/globalize#where-does-the-data-come-from

ponmani commented 6 years ago

Okay. Thanks. I will try.

On Mon 9 Apr, 2018, 1:20 PM Robin Herbots, notifications@github.com wrote:

@ponmani https://github.com/ponmani,

Sorry but I will not implement this very soon, as there already so many issues waiting.

Anyway, if you go for implementing it yourself. What need to be done is provide some mapping between the culture and the needed groupSeparator and radixPoint. (jquery.globalize does that already) You can define an option like culture in the numeric alias and if this is defined override the radixPoint and groupSeparator options. Within the numeric alias you have the mask function. When you add this in in front of the existing code it should work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobinHerbots/Inputmask/issues/1861#issuecomment-379665299, or mute the thread https://github.com/notifications/unsubscribe-auth/AGqOHstvgu9xxlvww_bhHWciNMIWGsuJks5tmxK2gaJpZM4TMEFX .

ponmani commented 6 years ago

which option call set input mask value for particular field?

ponmani commented 6 years ago

var isValsid = true,
maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), maskedValue = jQuery.format(Number(maskedValue), "n"), processValue = maskedValue.replace(opts.prefix, ""); processValue = processValue.replace(opts.suffix, ""); processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""); if (opts.radixPoint === ",") processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."); //handle negation symbol processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-"); processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""); processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue;