Mobile and local Brazilian phone MASK
-
Hi guys,
Could you please help me to improve this mask code?
It has some error like:
1- it accept letters – I want only numbers in this field.
2- if you input more than 15 digits, the field insert “—” istead of the numbersthank you
function before_load() { jQuery("#wdform_12_element1").on("keypress keyup",function(){ // pego o valor do telefone e coloco na variavel var texto = jQuery(this).val(); if (texto.length == 0) { texto = texto +"("; } if (texto.length == 3) { texto = texto +")"; } if (texto.length == 5) { if (texto.includes('9')) { texto = texto +"." ; } } if (texto.length == 12) { texto = [texto.slice(0, 8), "-", texto.slice(8)].join(''); } if (texto.length == 15) texto = [texto.slice(0, 8), texto.slice(9, 11), "-", texto.slice(11) ].join(''); jQuery(this).val(texto); } ) }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Mobile and local Brazilian phone MASK’ is closed to new replies.