jQuery UI Widgets Forums Editors MaskedInput Input Mask and MVC Model

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 3 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Input Mask and MVC Model #85394

    janets
    Participant

    I use the javascript routine (this is in an file not embedded in the view) below to set masked input on two MVC Views.
    The Model binding saves the mask and input when the data is saved to the database. This is not a problem but when I retrieve the data, It will not display correctly.
    How do I get this to work correctly? The setting of the ‘val’ syntax is a different format and does not work here.
    Please advise.
    (We have an enterprise license for Charlotte County BCC

    function applyMasks(formname) {
    $(document).ready(function () {

    if (formname == ‘create’) {
    $(‘#fedID’).jqxMaskedInput({ mask: ‘##-#######’, theme: ‘energyblue’ });
    $(‘#fedID’).select();
    }

    $(‘#BusinessPhone’).jqxMaskedInput({ width: ‘100%’, mask: ‘(###) ###-####’, theme: ‘energyblue’ });
    $(‘#BusinessPhone’).jqxMaskedInput({ value: ‘@Model.BusinessPhone’ });

    $(‘#BusinessPhone’).on(‘click’, function () {
    $(‘#BusinessPhone’).select();
    });
    $(‘#CellPhone’).on(‘focus’, function() {
    $(‘#CellPhone’).jqxMaskedInput({ width: ‘100%’, mask: ‘(###) ###-####’, theme: ‘energyblue’ });
    $(‘#CellPhone’).jqxMaskedInput({ value: ‘@Model.CellPhone’ });
    $(‘#CellPhone’).select();
    });

    $(‘#FaxPhone’).on(‘click’, function () {
    $(‘#FaxPhone’).jqxMaskedInput({ width: ‘100%’, mask: ‘(###) ###-####’, theme: ‘energyblue’ });
    $(‘#FaxPhone’).jqxMaskedInput({ value: ‘@Model.FaxPhone’ });
    $(‘#FaxPhone’).select();
    });
    $(‘#EmergencyContactPhone’).on(‘click’, function () {
    $(‘#EmergencyContactPhone’).jqxMaskedInput({ width: ‘100%’, mask: ‘(###) ###-####’, theme: ‘energyblue’ });
    $(‘#EmergencyContactPhone’).jqxMaskedInput({ value: ‘@Model.EmergencyContactPhone’ });
    $(‘#EmergencyContactPhone’).select();
    });
    });
    }

    Input Mask and MVC Model #85427

    Hristo
    Participant

    Hello janets,

    Do you have some error messages in the console?
    Also please check the format of the value that you set on this particular MaskedInput.
    (Hint: If you try to set number 1234 on [#]-### the result will be [2]-___ correct is to set string “[1]-234”)

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Input Mask and MVC Model #85441

    janets
    Participant

    If I save the value into the database as masked IE: (941) 475-7981 and I retrieve it and set the masked field using Value: the fields displays ( ) ___-____. When I inspect the DOM the value: (941) 475-7981 the aria-valuenow=”(___) ___-____”. The only way to get this to display is to strip the mask and pass all digits. The documentation is not clear as the difference between val and value. or not clear to me.
    I would prefer to store the mask in the database.

    Input Mask and MVC Model #85461

    Hristo
    Participant

    Hello janets,

    We have discussion about this. Please, take a look this topic:
    http://www.jqwidgets.com/community/topic/problem-re-populating-masked-input/#post-82511

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.