1

I want to add phone mask to my input. I found way how to do that, but it substring number "9". How can I make visible number "9". I need this view +994(__)___-__-__

$(window).load(function()
{
   var phones = [{ "mask": "+994(##) ###-##-##"}, { "mask": "+994(##) ###-##-##"}];
    $('#textbox').inputmask({ 
        mask: phones, 
        greedy: false, 
        definitions: { '#': { validator: "[0-9]", cardinality: 1}} });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.62/jquery.inputmask.bundle.js"></script>
<input type='text' id='textbox' />
Orik3ll0
  • 43
  • 1
  • 5
  • 11

1 Answers1

3

You can use escapeChar:

escapeChar: "\\"

add this before digit 9 and it will escape 9 in the mask.

$(window).load(function()
{
   var phones = [{ "mask": "+\\9\\94(##) ###-##-##"}, { "mask": "+994(##) ###-##-##"}];
    $('#textbox').inputmask({ 
        mask: phones, 
        greedy: false, 
        definitions: { '#': { validator: "[0-9]", cardinality: 1}} });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.62/jquery.inputmask.bundle.js"></script>
<input type='text' id='textbox' />
Mindless
  • 2,352
  • 3
  • 27
  • 51