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;
            alert("Wrong username of password");
        return false;

<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()" > 
            <div id="div2"> 
            <Log id="LogIn">Log In </Log> </div> 

Recommended Answers

All 2 Replies

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.

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.