Orik3ll0
Orik3ll0

Reputation: 43

html Phone mask

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' />

Upvotes: 1

Views: 5134

Answers (1)

Mindless
Mindless

Reputation: 2357

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' />

Upvotes: 3

Related Questions