1

I'm trying to make an easy login "system" with javascript. You can create a username and password and then log in or log out from a homepage div. When you use the login button, the login() function checks if the username and password are correct and let you to the homepage (hide the login div and show the homepage div). The problem is that when you then log out and want to log back in the values of your username and password are still there (as you just change divs by showing one and hiding other). This is the part of the code by which I'm trying to delete your input values.

$(".login_username").html("");
$(".login_password").html("");

This code is part of the login() function. I was trying to set the input value to an empty string but it doesn't work.

2
  • Please show the html if possible Commented Mar 16, 2019 at 0:57
  • What happens when the user refresh the page? Commented Mar 16, 2019 at 1:06

1 Answer 1

2

I don't know why you would authenticate in this way, but the way to empty inputs is basically to set their value to an empty string:

$(".login_username").val("");
$(".login_password").val("");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.