I am trying to validate the textbox in the login Xhtml and once I figured out the code, the section class'container' in the code is not working.
How can I write the code and validate the textbox properly?
<head>
<script type = 'text/javascript'>
function validate() {
if (document.getElementById("login").value == "") {
alert("User name may not be blank");
} else if (document.getElementById("password").value == "") {
alert("Password may not be blank.");
}
}
</script>
<title>Login Form</title>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<h1> Login</h1>
<section class="container">
<div>
<form method="post" action="index.xhtml" onsubmit="return validate();">
<p>
<input type="text" name="login" value="" id="login" placeholder="Username or Email" />
<input type="password" name="password" value="" id="password" placeholder="Password" />
</p>
<p>
<label>
<input type="checkbox" name="remember_me" id="remember_me" />Remember me on this computer
</label>
</p>
<p class="submit">
<input type="submit" name="commit" value="Login" onclick="validate();" />
<button type="reset" value="Clear">Clear</button>
</p>
</form>
<form action= "http://localhost:8080/ChattBank/LoginServlet" method="post"/>
</div>
</section>
</body>