Forum Post: How should I read the values of input fields to set them as local storage...

  • Thread starter Thread starter jsniemi79
  • Start date Start date
Status
Not open for further replies.
J

jsniemi79

Guest
I am trying to save the user and password values on my app to eliminate typing. My user is an input field with a text type and my password is an input field with the password type. I am running the following javascript on value change of a toggle button that I added to my login screen. My variables are both being logged currently as undefined. var a = $(this).val(); var name = $('#usernameValue').val(); var pw = $('#passwordValue').val(); console.log(name); console.log(pw); if (a == 'on') { localStorage.setItem("UserID",name); localStorage.setItem("Password",pw); } else { localStorage.setItem("UserID",''); localStorage.setItem("Password",''); } What is the correct syntax to return the on screen values of the my user and password input fields.

Continue reading...
 
Status
Not open for further replies.
Back
Top