0

Can anyone help me for this problem ?.. I have a Log-in form and i want to validate the username and password to log-in but the account is default. This is my Code

<html> <head> <title></title> <script>
    function LogIn(){
        user = document.getElementById("User").value;
        pass = document.getElementById("Pass").value;
        use = "1";
        if(user == "1"){
            alert("Welcome Admin");
            return true;
        }else{
            alert("Wrong username of password");
        return false;
        }
    }

</script> 
</head> 
<body> 
<div id="div1"> 
<fieldset id="field"> <form action="Menu.html" method="get">
<Us id="User">Username:</Us><br><br> 
            <input type="text"  id="Username" placeholder="Username"><br><br> 
    <Pas id="Pass">Password:</Pas><br><br> 
            <input type="Password"  id="Password" placeholder="Password"><br><br> 
            <input type="submit" id="Submit" value="LogIn" onClick="LogIn()" > 
            </form> 
            </fieldset> 
            </div> 
            <div id="div2"> 
            <Log id="LogIn">Log In </Log> </div> 
            </body> 
            </html> 

Edited by Reverend Jim: Moved to Web Development forum

2
Contributors
2
Replies
16
Views
1 Year
Discussion Span
Last Post by Richmond_1
0

These don't match:
<input type="text" id="Username" placeholder="Username">
user = document.getElementById("User").value;

The <Us> element has an ID of User so you're selecting the wrong element.

0

Owh.. hahaha Thanks a lot sir hericles.. thats the result of my over fatigue, can't see clear lol .. BTW Thanks for the help :D (y)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.