RobinHerbots / Inputmask

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

numeric Alias: unmaskAsNumber #1971

Open bippesbrandao opened 6 years ago

bippesbrandao commented 6 years ago

Hi! it's more a feature request than a bug. unmaskAsNumber works as expected to reformat german number format to JS-Format. With this option enabled unmask returns the value of the input field casted as number. This breaks the default behaviour of $('input[type="text"]').val() as this usually returns a string.

The "problem" I'm facing is that some libs are expecting a string (e.g. jQuery-form). Since they are doing some string operation on the fields - they crash (e.g. Uncaught TypeError: e(...).val(...).replace is not a function).

I think it shouldn't be inputmasks job to cast values, but I understand if you don't want to break current behaviour. So I vote for a (weird sounding) option like "unmaskAsNumberString": ... (opts.unmaskAsNumberString ? processValue : Number(processValue) ) ) : processValue; ...

best regards and many thanks for your great work! Arne

bippesbrandao commented 6 years ago

Sorry duplicate to #1288

RobinHerbots commented 6 years ago

I just reopen to rethink about the issue. I'm currently on holiday, but i need to look at the unmask function.