Search code examples
x-editablemaskedinput

x-editable + maskedinput returning underscores on enter but not on click


x-editable + maskedinput returning underscores from maskedinput on enter but it does not when I click. Any ideas on how to fix this?

JSFiddle:

jQuery Library's:

HTML:

<a href="#" data-pk="1">1</a>

JS:

$('a').editable({
    type: 'text',
    name: 'username',
    tpl: '<input type="text" id ="zipiddemo" class="mask form-control input-sm dd" style="padding-right: 24px;">'
});

$(document).on("focus", ".mask", function () {
    $(this).mask("?999");
});

Solution

  • JSFiddle:

    HTML:

    <a href="#" data-pk="1">1</a>
    

    JS:

    $('a').editable({
        type: 'text',
        name: 'username',
        tpl: '<input type="text" id ="zipiddemo" class="mask form-control input-sm dd" style="padding-right: 24px;">',
        display: function(value, response) {
            return false;
        },
        success: function(response, newValue) {
            $(this).html(newValue.replace(/_/g, ''));
        },
    });
    
    $(document).on("focus", ".mask", function() {
        $(this).mask("?999");
    });