登入成功後重定向到html中的另一個頁面
P粉729518806
P粉729518806 2024-03-20 09:29:07
0
1
300

我無法重定向到另一個頁面,它所做的只是顯示我在網址中輸入的密碼和使用者。然而,當我使用 window.open(); 時,它確實可以在 YouTube 等連結中運作。我嘗試了在 youtube 上看過的各種程式碼,但我仍然不知道該怎麼做

<!DOCTYPE html>
 <html>
    <head>
    </head>
    <body>
    <div class="login-wrapper">
    <form action="" class="form">
        <h2> Login </h2><br>
    <div class="input-group">
        <label for="id">User ID </label>
        <input type="text"
         name="id"
         id="User ID"
        placeholder="User ID"
         required />
    </div>
    <div class="input-group">
        <label>Password </label>
        <input type="password"
         name="password"
         placeholder="Password"
        id="password" required />
     </div>
    <input type="submit" value="Login" class="submit-btn" onclick= "auth()" style="font-size:18px;" />
    </form>
    </div>
    <script>
        function auth(){
        var UserID = document.getElementById("UserID").value;
        var password = document.getElementById("password").value;
        if(UserID== "admin" && password=="admin123"){
    
        window.location.href="teachergui.html";
        alert("Login Successfully ");
        }
        else{
        alert("Invalid User");
        return;
        }
    }
    </script>
    </div>
    </body>
</html>

#
P粉729518806
P粉729518806

全部回覆(1)
P粉154798196

您正在使用程式碼呼叫該值:

var UserID = document.getElementById("UserID").value;

#但是您輸入的 UserID 有一個空格:

#
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!