0

index.js:12 Uncaught TypeError: Cannot read property 'value' of null at index.js:12


Here's my code (html):

<html>
<head>
    <title>Test</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
    <link href="stylesheet.css" rel="stylesheet">
    <script src="index.js"></script>
</head>
<body>
    <h1 id="title">Test</h1>
    <hr>
    <h1 id="login_title">Login to access website</h1>
        <label id="uname"><b>Username</b></label>
        <input type="text" placeholder="Enter Username" name="uname" id="username" required>
    
        <label id="psw"><b>Password</b></label>
        <input type="password" placeholder="Enter Password" name="psw" id="password" required>
    
        <button id="submit" type="submit">Login</button>
</body>

(js)

console.log(document.getElementById("password").value)

And of course the error is Cannot read property 'value' of null

0 Answers0