I am trying to do some simple form validation in a JSP. But the javascript just does not work....as if its just not there. Dont know what is amiss.
Here is my code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script>
function validateForm()
{
if(document.frm.login.value=="")
{
alert("User Name should be left blank");
document.frm.login.focus();
return false;
}
else if(document.frm.password.value=="")
{
alert("Password should be left blank");
document.frm.password.focus();
return false;
}
}
</script>
<title>Insert title here</title>
</head>
<body>
<img src="cs6.jpg" width=1200 Height=200 alt="some_text"/>
<div style="
margin-top:50px;
margin-left:100px;
margin-right:100px;
margin-bottom:50px;
">
<div style="width:500px;height:200px;border:2px solid blue;
padding-top:100px;
padding-left:120px;
padding-right:50px;
padding-bottom:20px;
">
<form action = "LoginServlet" method = "post" name = "frm" onsubmit = "return validateForm()">
<table cellspacing="5" border="0">
<tr>
<td align="right"">Login:</td>
<td><input type="text" name="login"></td>
</tr>
<tr>
<td align="right"">Password:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td align="center"></td>
<td><input type="submit" value="Submit" ></td>
</tr>
</form>
</table>
</div>
</div>
</body>
</html>