jQWidgets Forums

jQuery UI Widgets Forums Editors MaskedInput masks with variable length

This topic contains 4 replies, has 2 voices, and was last updated by  Hugo 10 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • masks with variable length #61886

    Hugo
    Participant

    Hi,

    how to make the masks with variable length

    example:

         
            $("#jqxMaskedInput").jqxMaskedInput({ mask: '(##) ####-####?#' }); //accepts 10 or 11 digits
    
    masks with variable length #61916

    Dimitar
    Participant

    Hello Hugo,

    If you set your mask to “(##) ####-####[ |0-9]” it will accept either a Space bar or a number as a last character, making it appear as a 10- or 11-digit mask respectively.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    masks with variable length #61958

    Hugo
    Participant

    Hi Dimitar,

    not good, with 10 digits the space of 11º digit is visible, it would have to vanish

    with 10 digits is thus: (11) 2222-3333_ would have to disappear “_” if 10 digits

    thought about it but does not work

     $("#jqxMaskedInput").jqxMaskedInput({
         width: '250px',
         height: '25px',
         mask:'(##) ####-####[0-9]',
     }).on('change', function(e){
         var value = e.args.value.replace(/[^0-9]/g,'');
         if( value < 11 ){
             $("#jqxMaskedInput").jqxMaskedInput({ mask:'(##) ####-####' }); // 10 digit
         }else{
             $("#jqxMaskedInput").jqxMaskedInput({ mask:'(##) #-####-####' }); // 11 digit
         }
         $('#jqxMaskedInput').jqxMaskedInput('val', value);
     });
    
    masks with variable length #61962

    Dimitar
    Participant

    Hi Hugo,

    In our solution, you would have to press Space bar if you wish the last prompt character to be invisible, e.g.: “(11) 2222-3333 ” if you wish to have just 10 digits. Other solutions are not available, unfortunately.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    masks with variable length #61975

    Hugo
    Participant

    Okay 🙁

    Thanks @dimitar

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

You must be logged in to reply to this topic.