While that code does work, it is not what I am looking for. the .getItem() will return null if the key does not exist. My code tests for that correctly. The problem I am having is before I even get to that, I want a separate loop that tests the inputed username+password and checks to see that it has not already been submitted.
Something like:
Code:
while($("#username").val() +";"+ $("#password").val() != localStorage.getItem(x));
{
if($("#username").val() +";"+ $("#password").val() == localStorage.getItem(x))
{
break;
alert("Account Already Listed");
}
x++;
}
It includes jQuery and its confusing that's why I was asking more generally. This is what I intend:
Code:
while(username+password is not in localStorage)
{
if(username+password is in localstorage)
{
break;
alert("account in storage");
}
x++
}
I can't get it to break correctly and it continues looping. Maybe I am ordering or wording it wrong. The while loop does good while the condition is true, but I want a specified action to happen when it fails.