My HTML/jQuery login doesn't work

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
My jQuery code does not work. Please help, I have no idea what is wrong. I am new to jQuery so it’s possible that I am doing something wrong.

```

<%@ Page Language=“C#” AutoEventWireup=“true” CodeFile=“Default2.aspx.cs” Inherits=“Default2” %>

 
Username:  
Password:  
 

 
 
$(document).ready(function myfunc() { $('#Text1').keyup(function() { var txtValue = $(this).val(); }); $('#Password1').keyup(function () { pwdValue = $(this).val(); }); if (txtValue === "Reece") { if (pwdValue === "12345") { $('#conformation').text('Unlocked!'); $('#conformation').after('
') $('#br1').after('

UserName: ' + txtValue + '

'); $('#unp').after('
'); $('#br2').after('

Password: ' + pwdValue + '

')
            }
        } else {
            alert("Invalid");
        }
        $('.button').mouseenter(function() {
            $(this).fadeTo('fast', 1);
        });
        $('.button').mouseleave(function () {
            $(this).fadeTo('fast', 0.5);
        });
    });
</script>
<style type="text/css">
    .button {
background-color: #008CBA; /* Green */
border-radius: 10px;
color: white;
text-align: center;
font-size: 16px;
width: 100px;
height: 40px;

}
.auto-style1 {
width: 63px;
}


Locked!


<do not remove the three backticks above>

@lividtea2
As a start
You are aware you will run this in an ASP.net environment ??

Your <style></style> element should be in the <header></header> element
http://stackoverflow.com/questions/1303416/does-style-have-to-be-in-the-head-of-an-html-document

In your <script> you are using an IF-ELSE statement

  • which will be evaluated as soon as jQuery’s READY-eventflag has been set…
  • but the IF-ELSE condition has dependencies with the #Text1 and #Password1 =keyup= Eventhandler’s

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.