javascript - Hide/Show validation form issue -


I want to create a simple verification form, but Ive found a little error in fixing the file. After clicking on the login entry I see a login_window (varies from display: none to display: block) then I want to show login and password input When I fill in something other than "Username" and "Password", then I should be shown a alert message. Instead, it keeps hiding the login_windows even when there is no form (I just submit and login_windows Hidden)

HTML:

  & lt; Div id = "login_window" & gt; & Lt; form name = "login_form" onsubmit = "return validate_login ()" method = "post" & gt; & Lt; Label & gt; Login & lt; / Labels & gt; & Lt; Input type = "text" name = "usr" placeholder = "user name" & gt; & Lt; Br> & Lt; Label & gt; Sign in & lt; / Labels & gt; & Lt; Input type = "text" name = "psw" placeholder = "password" & gt; & Lt; Br> & Lt; Input type = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; / Div & gt;   

CSS:

  #login {status: absolute; Width: 65px; Height: 26px; } # Login_windows {status: complete; Width: 400px; Height: 460px; Background color: # F0F0F0; Z-index: 2; }   

JS:

  var login = document.getElementById ("Login"); Var login_windows = document.getElementById ("login_windows"); Login_window.style.display = "none"; Login.addEventListener ("click", function () {login_window.style.display = "block";}); Function validate_login () {var un = document.login_form.usr.value; Var pw = document.login_form.psw.value; Var Username = "User Name"; Var password = "password"; If ((United Nations == username) & amp; amp; (PW == password)) {back true; } And {warnings ("Login was reluctant, please enter compass name and password."); return false; }}   

here

Even though it works differently in Baila in my browser, I have two questions.

1) Why does the login_window hide when I click submit?

2) Why is my verification not working?

Thanks

If you move your function to the body, Available when available, it works.

  No wrapped - & lt; body & gt;   

In addition, please do the programmers like them so much in your Correct Warning Messages? : -)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -