Tell us what’s happening:
the points 35 and 36 do not pass me the others pass without problems.
[ReferenceError: resultsDiv is not defined], by the console I have it defined, what am I doing wrong?
Your code so far
<!-- file: index.html -->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Validator TELF</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container-cabecera">
<h1>Validator TELFS</h1>
<img src="https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg" class="logo"/>
</div>
<div class="containerInput">
<input type="text" id="user-input"/>
<button id="check-btn" onClick="checkInputRegex()">Check</button>
</div>
<button id="clear-btn" onClick="clearButton()">Clean</button>
<div id="results-div">Results</div>
</div>
<script src="script.js"></script>
</body>
</html>
/* file: script.js */
const result = document.getElementById("results-div")
const inputCheck = document.getElementById("user-input")
const buttonCheck = document.getElementById("check-btn");
const buttonClear = document.getElementById("clear-btn")
function checkInputRegex() {
if (inputCheck.value === "") {
alert("Please provide a phone number");
}
let checkInput = inputCheck.value;
let rex1 = /^(1\s?)?(\(\d{3}\)|\d{3})[\s-]?\d{3}[\s-]?\d{4}$/;
if (rex1.test(checkInput)) {
let text = `Valid US number: ${checkInput}`
result.textContent = text
} else {
let text1 = `Invalid US number: ${checkInput}`
result.textContent = text1
}
}
function clearButton() {
console.log("hello")
const element = document.getElementById ("results-div");
element.textContent = "";
}
/* file: styles.css */
body{
text-align: center;
background-color:rgb(21, 20, 49);
color: white;
}
.logo{
width: 100px;
height: 30px;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Challenge Information:
Build a Telephone Number Validator Project - Build a Telephone Number Validator