Remove input data using a function

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.

728x90

1 Answers Remove input data using a function

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("");

1 weeks ago