DEV Community


Posted on

How to redirect after logged in (simple javascript)

i need some help with my code. Basicaly i am not able to redirect after logged in.
SO i need some help with that.
I used simple html and javascript
html is here and js is down


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="login.css">
    <script src="login.js"></script>

     <DIV action="login.html" class="container">
         <form  method="POST" class="login-form">
            <h1 class="login-heading">LOGIN FORM</h1>
             <input type="text" placeholder="User Name" id="login-username">
             <input type="password" placeholder="Password" id="login-password">
             <input type="submit" value="Login" id="login-submit" onclick="validate()">

Enter fullscreen mode Exit fullscreen mode



function validate(){
    var username=document.getElementById('login-username').value;
    var passowrd=document.getElementById('login-password').value;

    if (username === "daksh" && passowrd === 'daksh'){
        alert('You have sucessfully logged in');

    } else{
        alert('Wrong username or password');
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

daksh100sharma profile image
daksh100sharma Author

? bruh if you can help so help.

Some comments have been hidden by the post's author - find out more