Thursday, 5 September 2013

HTML5 Local Storage not storing value from password box

HTML5 Local Storage not storing value from password box

I have written a HTML file, and it contains two entry boxes, one is called
username and the other called password. Something like this:
<input class='registerinput' id='registerusername'
placeholder='Username'></input>
<input class='registerinput' id='registerpassword' placeholder='Password'
type='password'></input>
<input class='registerinput' id='registerpasswordrepeat'
placeholder='Repeat Password' type='password'></input>
And I want to store it into a local storage using these codes.
if (document.getElementById('registerusername').value != "") {
localStorage.username=document.getElementById('registerusername').value }
else if (document.getElementById('registerusername').value == "") {
alert('You must enter a username.') }
if (document.getElementById('registerpassword').value != "" &&
document.getElementById('registerpasswordrepeat').value ==
document.getElementById('registerpassword').value) {
localStorage.password==document.getElementById('registerpassword'.value)
}
else if (document.getElementById('registerpassword').value == "") {
alert('You must enter a password') }
if (document.getElementById('registerpasswordrepeat').value !=
document.getElementById('registerpassword').value) {
alert('The password did not match.') }
Everything worked except I cannot save the value in password box. Is it a
HTML5 storage limitation for security or a bug in my code? Thanks.

No comments:

Post a Comment