Mask for telephone field

0

How can you mask in a phone input only to accept numbers and already enter the formatting (xx) xxxxx-xxxx

    
asked by anonymous 09.05.2018 / 20:51

2 answers

3

I learned on this site even, to use this instance, as follows:

$("#telefone, #celular").mask("(00) 0000-0000");
 <script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>
 
 <label>Telefone</label>
<input type="text" class="form-control" placeholder="Telefone" id="telefone" name="telefone" ><br>
<label>Celular</label>
<input type="text" class="form-control" placeholder="Celular" id="celular" name="celular" ><br>
        
09.05.2018 / 20:56
1

Using jQuery, you can do as follows:

$('#id_do_campo').mask('(99) 99999-9999');
    
09.05.2018 / 20:58