Here is the HTML form I have created:
<form accept-charset="utf-8" onsubmit="return validateForm()">
<input placeholder="Enter Username" type="text" id="user">
<input placeholder="Enter Your Password" type="password" id="pass">
<button>Login</button>
</form>
This is the JavaScript code included in the head section:
<script type="text/javascript">
function validateForm() {
var username = document.getElementById("user").textContent;
alert(username);
return false;
}
</script>
I am facing an issue with the code. Even though my syntax is correct, when I enter a value in the username field and click the login button, the JavaScript code displays a blank value. This code was working fine yesterday, but today it's not showing the input values. Can someone help me understand why this is happening?