TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed salah
NA
530
148.7k
If username stored in local storage open new web page
Aug 4 2016 7:11 AM
I have web page index have two input type text username and username2
and checkbox save and button save when client write username and username2 and checkbox save checked then click save button
it will store in local storage i dont have any problem in that
I need actually if username and username2 exist or stored in local storage go to web page index2
my code as bellow working but only i need to modify it if exist local storage go to web page index2
@{
Layout =
null
;
}
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width"
/>
<title>Index</title>
<script src=
"~/Scripts/jquery-1.10.2.js"
></script>
<script>
$(
function
() {
if
(localStorage.chkbx && localStorage.chkbx !=
''
) {
$(
'#save'
).attr(
'checked'
,
'checked'
);
$(
'#username'
).val(localStorage.username);
$(
'#username2'
).val(localStorage.username2);
}
else
{
$(
'#remember_me'
).removeAttr(
'checked'
);
$(
'#username'
).val(
''
);
$(
'#username2'
).val(
''
);
}
$(
'#btn'
).click(
function
() {
if
($(
'#save'
).is(
':checked'
)) {
// save username and password
localStorage.username = $(
'#username'
).val();
localStorage.username2 = $(
'#username2'
).val();
localStorage.chkbx = $(
'#save'
).val();
}
else
{
localStorage.username =
''
;
localStorage.username2 =
''
;
localStorage.chkbx =
''
;
}
});
});
</script>
</head>
<body>
<div
class
=
"container"
>
<form
class
=
"form-signin"
>
<h2
class
=
"form-signin-heading"
>Please sign
in
</h2>
<input type=
"text"
class
=
"input-block-level"
placeholder=
"username"
id=
'username'
>
<input type=
"text"
class
=
"input-block-level"
placeholder=
"username2"
id=
"username2"
>
<label
class
=
"checkbox"
>
<input type=
"checkbox"
value=
"save"
id=
"save"
> save
</label>
<button
class
=
"btn btn-large btn-primary"
id=
"btn"
type=
"submit"
>save</button>
</form>
</div>
</body>
</html>
Reply
Answers (
3
)
[Ask] Jquery auto complete more than one column
Could not position the SVG Element.