0
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form name="loginForm" method="post" action="login.php">
<table width="20%" bgcolor="0099CC" align="center">

<tr>
<td colspan=2><center><font size=4><b>HTML Login Page</b></font></center></td>
</tr>

<tr>
<td>Username:</td>
<td><input type="text" size=25 name="userid"></td>
</tr>

<tr>
<td>Password:</td>
<td><input type="Password" size=25 name="pwd"></td>
</tr>

<tr>
<td ><input type="Reset"></td>
<td><input type="submit" onclick="return check(this.form)" value="Login"></td>
</tr>

</table>
</form>
<script language="javascript">
function check(form)
{

if(form.userid.value == "meet" && form.pwd.value == "meet")
{
    return true;  (I need to add it here) window.location.replace("http://stackoverflow.com");  (checked) window.location.href = "http://stackoverflow.com"; (checked)

}
else
{
    alert("Error Password or Username")
    return false;#using windows replace shows incoorect id
}
}
</script>

</body>
</html>

this is one of my login page and i need to redirect it if the condition is true.

Rakesh KR
  • 6,357
  • 5
  • 40
  • 55
meet
  • 1
  • 1
  • 1
    Meet, Welcome to Stackoverflow. Refer https://stackoverflow.com/questions/5411538/redirect-from-an-html-page – Rakesh KR Jun 25 '22 at 05:24

1 Answers1

0
  • In case the condition is true through the if itself, without the need to return true you could directly redirect to the page through window.location.href = "route", otherwise just send the alert.