Build a Telephone Number Validator Project - Build a Telephone Number Validator

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

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

you need here ./script.js

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.