0

i m creating simple demo sign in form using local storage and javascript/jquery. i used bootstrap forms for same. but i m receiving following error

VM126:1 Uncaught SyntaxError: Unexpected token r in JSON at position 0 at JSON.parse ()

here is my javascript code

$(document).ready(function(){
        $("#submit").on("click", function(){
            usersdata = JSON.parse( localStorage.getItem('firstname') );
            var userfirstname  = document.getElementById("fname");
            var userlastname   = document.getElementById("lname");
            for(var i in usersdata)
                    {
                        if(userfirstname==usersdata[i].fname)
                            {
                                alert("Logged in successfully");
                            }
                    }   
}); 
});

i follow this link for creating login validation from local storage how to retrieve data from local storage?

i also searched other links having discussing same issue but they were creating page using ajax calls. i m not adding any ajax call here(though i have to afterwards). i want to create simple login. any suggestion will be appreciated!

rc49
  • 1
  • 1

0 Answers0