question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get unmasked value in oncomplete

See original GitHub issue

Hi! Use this great plugin, but have small problem I need to send value from field for statistic purposes with this code (value could be 10 or 12 numbers):

$('#Inn').inputmask({
    mask: "9999999999[99]",
    autoUnmask: true,
    removeMaskOnSubmit: true,
    oncomplete: function (e)
    {
        var inn = e.target.value;
        $.getJSON('/sendData?inn=' + encodeURIComponent(inn));
    }
});
XHR finished loading: GET "http://localhost/sendData?inn=2311113226__".

Only when I get another call for unmasked values all goes ok:

$('#Inn').inputmask({
    mask: "9999999999[99]",
    autoUnmask: true,
    removeMaskOnSubmit: true,
    oncomplete: function ()
    {
        var inn = $('#Inn').inputmask('unmaskedvalue');
        $.getJSON('/sendData?inn=' + encodeURIComponent(inn));
    }
});
XHR finished loading: GET "http://localhost/sendData?inn=2311113226".

Is it right way to get unmasked value in “oncomplete” hanlder?

P.S.: Using jQuery 1.11.2 and jquery.inputmask 3.1.62

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Alex-Sokolovcommented, Apr 14, 2015

Ok! I think var inn = this.value; will work the same way for simple text input

1reaction
RobinHerbotscommented, Apr 14, 2015

@Alex-Sokolov ,

You can also just do

$('#Inn').inputmask({
    mask: "9999999999[99]",
    autoUnmask: true,
    removeMaskOnSubmit: true,
    oncomplete: function ()
    {
        var inn = $('#Inn').val();
        $.getJSON('/sendData?inn=' + encodeURIComponent(inn));
    }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery.inputmask - set value in "oncomplete" callback makes ...
It seems as though you have uncovered a critical bug with the jQuery inputmask plugin. There is some aggressive caret position handling when...
Read more >
Input Mask Guide | imaskjs
Get /set value and unmasked value: masked.value = 'hello world!'; console.log(masked.unmaskedValue); // or typed value if it makes sense console.log(masked.
Read more >
A jQuery Plugin to make masks on form fields and html ...
jQuery-Mask-Plugin - A jQuery plugin to make field masks. ... $(selector).unmask(); /** Gets the value of the field without the mask.
Read more >
jquery.inputmask - UNPKG
7, Inputmask is a javascript library which creates an input mask. ... 27, - value formatting / validating without input element ... 669,...
Read more >
commitMutation | Relay
The value passed to onCompleted is the the mutation fragment, ... This means that data from within unmasked fragments will not be read, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found