/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> function MascaraTEL(campo, teclaPress) { if (window.event){ var tecla = teclaPress.keyCode; } else { tecla = teclaPress.which; } var s = new String(campo.value); s = s.replace(/(\.|\(|\)|\/|\-| )+/g,''); tam = s.length + 1; if (tam > 4 && tam < 9) campo.value = s.substr(0,4) + '-' + s.substr(4, tam); } <script/> <!--Campo Telefone--> <input type="text" onkeyup="MascaraTEL(this, event);"/>
Comments
