Here is the code
<script>
require([
"jquery"
], function($) {
'use strict';
$(document).ready(function () {
setTimeout(
function(){
let telephone = $('input[name="telephone"]');
telephone.keypress(function() {
console.log("Formatting phone number with keypress");
telephone.attr('maxLength', '13');
telephone.attr('minLength', '13');
telephone.addClass('validate-phone-13');
telephone.attr('type','tel');
let x = $(this).val();
x = x.replace(/D+/g, '').replace(/(d{3})(d{3})(d{4})/, '($1)$2-$3');
$(this).val(x);
});
telephone.focusout(function(){
console.log("Formatting phone number with focusout");
let x = $(this).val();
x = x.replace(/D+/g, '').replace(/(d{3})(d{3})(d{4})/, '($1)$2-$3');
$(this).val(x);
});
}, 8000);
});
});
</script>
This script loads in DOM and I can see the code when inspecting. but it doesn’t execute code. it works fine on the local machine.
Does it have to do something with timeout time?