Hi,
I am kindaa new to javaScripts. I have written the Following java Serer page
<html>
<head>
<style type="text/css">
div
{
position:absolute;
left:440px;
top:350px;
}
</style>
<script type="text/javascript" >
function validate()
{
var id = document.userpass.id.value;
alert (document.userpass.id.value);
alert(id);
if((id == null)) then
{
alert("User id cannto be null");
document.userpass.id.focus;
return false;
}
return true;
}
</script>
</head>
<body >
<form name="userpass" action="validate" method="POST" onSubmit="return validate()" >
<div>USER ID :<input type="text" name="id" ><br>
Password :<input type="password" name="password"><br>
<input type="submit" value="Login" ></div>
</form>
<body>
</html>
The problem is whenver i enter the USER ID . it is displayed in the Alert Window. However it goes inside the IF looop and the form is not submitted. IE it exactly performs the opposite of what it is supposed to do.. please help me out.
I am kindaa new to javaScripts. I have written the Following java Serer page
<html>
<head>
<style type="text/css">
div
{
position:absolute;
left:440px;
top:350px;
}
</style>
<script type="text/javascript" >
function validate()
{
var id = document.userpass.id.value;
alert (document.userpass.id.value);
alert(id);
if((id == null)) then
{
alert("User id cannto be null");
document.userpass.id.focus;
return false;
}
return true;
}
</script>
</head>
<body >
<form name="userpass" action="validate" method="POST" onSubmit="return validate()" >
<div>USER ID :<input type="text" name="id" ><br>
Password :<input type="password" name="password"><br>
<input type="submit" value="Login" ></div>
</form>
<body>
</html>
The problem is whenver i enter the USER ID . it is displayed in the Alert Window. However it goes inside the IF looop and the form is not submitted. IE it exactly performs the opposite of what it is supposed to do.. please help me out.