jQuery UI Widgets Forums Editors MaskedInput phone mask-digit

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 9 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • phone mask-digit #72965

    coni
    Participant

    hi~

    I would like to express a mask depends on the phone number digits.

    ex : 010-123-1234, 010-1234-1234

    So I looked create the code.

    
    $("#Phone").jqxMaskedInput({
    					width : 150,
    					height : 30,
    					mask:'###-###-####',
    				 }).on('valueChanged', function(e){					 
    				     var val = e.args.value.replace(/[^0-9]/g,'');
    				     console.info(val);
    				     if( value.length < 11 ){
    				         $("#Phone").jqxMaskedInput({ mask:'###-###-####',value : val }); // 10 digit
    				     }else{
    				         $("#Phone").jqxMaskedInput({ mask:'###-####-####',value : val }); // 11 digit
    				     }				     				     
    				 });
    

    https://jsfiddle.net/jqwidgets/sNbe7/

    I do not know whether the cursor is always the last thing …

    phone mask-digit #72979

    Dimitar
    Participant

    Hi coni,

    Please refer to the forum topic masks with variable length to see how you may be able to implement this functionality.

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.