Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Need Javascript Help!?

Hey guys, I am trying to create a form using javascript and HTML, this is what I have but it is not working:

<script>

<!--

var Login == document.getElementsByName("Login");

function myFunction()

{

if(Login == Admin){

alert("You are authenticated.");

}

}

//--

</script>

<form id="form1" name="form1" method="post" action="">

<p>

<label for="Login">Login:</label>

<input type="text" name="Login" id="Login" />

</p>

<input type="submit" name="Submit" id="Submit" value="Submit" onclick="myFunction()"/>

</form>

Cheers

1 Answer

Relevance
  • ?
    Lv 4
    8 years ago
    Favorite Answer

    <html>

    <head>

    <title>test</title>

    </head>

    <body>

    <script>

    function myFunction()

    {

    var str = document.getElementsByName("Login")[0];

    if(str.value == "Admin")

    alert("You are authenticated.");

    else

    alert("You are not admin");

    }

    </script>

    <form id="form1" name="form1" method="post"

    action="">

    <p><label for="Login">Login:</label>

    <input name="Login" id="Login" value=""

    type="text"></p>

    <input name="Submit" id="Submit" value="Submit"

    onclick="myFunction()" type="submit">

    </form>

    </body>

    </html>

Still have questions? Get your answers by asking now.