i have js code when user write ccc it turns to www
i have tested it and work fine in separate html file
HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real-time Text Replacement</title>
</head>
<body>
<label for="textInput">input:</label>
<input type="text" id="textInput">
<script>
// Select all input fields
const inputFields = document.querySelectorAll("input");
// Attach the event listener to each input field
inputFields.forEach(inputField => {
inputField.addEventListener("input", () => {
const currentText = inputField.value;
const updatedText = currentText.replace(/ccc/g, "www");
inputField.value = updatedText;
});
});
</script>
</body>
</html>
but when i write JS in Server Events > Global > All Pages > Page_Head
it not working
echo '
<script>
// Select all input fields
const inputFields = document.querySelectorAll("input");
// Attach the event listener to each input field
inputFields.forEach(inputField => {
inputField.addEventListener("input", () => {
const currentText = inputField.value;
const updatedText = currentText.replace(/ccc/g, "www");
inputField.value = updatedText;
});
});
</script>
';
any suggestion ?