How to allow only a few numbers in the product description,

asdriel

Member
Apr 26, 2019
198
17
18
www.bantu-2rsn.com
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;

}
}
 

Forum statistics

Threads
69,752
Messages
912,222
Members
242,566
Latest member
15730016

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu