asdriel
Member
Hello guys, I have this code to allow only a few numbers in the product description, but it doesn't work, any help?
I intend to allow only 5 or 4 numbers in the product description
whether or not to allow the number to start with 9
jQuery(document).ready(function() {mudarPhone();});
jQuery(document).load(function() {mudarPhone();});
let box = document.querySelector('.product-modal-content');
function mudarPhone() {
var textoAntigoDaDescricao = document.querySelectorAll('.woocommerce-product-details__short-description');
for (let i = 0; i < textoAntigoDaDescricao.length; i++) {
var formatodophone1 = /([0-9]{3})\)?[ - ]?([0-9]{3})[ - ]?([0-9]{3})/g;
var formatodophone2 = /([0-9]{3})\)?[ - ]?/g;
textoAntigo = textoAntigoDaDescricao.innerHTML;
textoAntigo = textoAntigo.replace(formatodophone1, "9xx xxx xxx");
textoAntigo = textoAntigo.replace(formatodophone2, "9xx");
textoAntigoDaDescricao.innerHTML = textoAntigo;
}
}
I intend to allow only 5 or 4 numbers in the product description
whether or not to allow the number to start with 9
jQuery(document).ready(function() {mudarPhone();});
jQuery(document).load(function() {mudarPhone();});
let box = document.querySelector('.product-modal-content');
function mudarPhone() {
var textoAntigoDaDescricao = document.querySelectorAll('.woocommerce-product-details__short-description');
for (let i = 0; i < textoAntigoDaDescricao.length; i++) {
var formatodophone1 = /([0-9]{3})\)?[ - ]?([0-9]{3})[ - ]?([0-9]{3})/g;
var formatodophone2 = /([0-9]{3})\)?[ - ]?/g;
textoAntigo = textoAntigoDaDescricao.innerHTML;
textoAntigo = textoAntigo.replace(formatodophone1, "9xx xxx xxx");
textoAntigo = textoAntigo.replace(formatodophone2, "9xx");
textoAntigoDaDescricao.innerHTML = textoAntigo;
}
}