Tell us what’s happening:
Describe your issue in detail here.
Step 5: When you click on the #check-btn
element without entering a value into the #user-input
element, an alert should appear with the text "Please provide a phone number"
. is not showing complete for me. However, when I am doing this in vscode it shows the alert whenever I click on check-btn when user-input is empty. Am I missing something?
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<label for="user-input">Enter a Phone Number:</label>
<input id="user-input">
<button id="check-btn">Check</button>
<button id="clear-btn">Clear</button>
<div id="results-div"></div>
<script src="/script.js"></script>
</body>
</html>
/* file: styles.css */
/* file: script.js */
const userInput = document.getElementById('user-input')
const checkBtn = document.getElementById('check-btn')
const clearBtn = document.getElementById('clear-btn')
checkBtn.addEventListener('click', () => {
if(!userInput.value){
alert("Please provide a phone number")
return
}
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Challenge Information:
Build a Telephone Number Validator Project - Build a Telephone Number Validator