Java implementation application remembers user name, password function

Source: Internet
Author: User

1. Download jquery.cookie.js from the Internet and copy to the application.

2. Login page (login.jsp) Import jquery.cookie.js

<script type= "Text/javascript" >
$ (function () {
var n = $.cookie (' username ');
var p = $.cookie (' password ');
$ ("#username"). Val (n);
$ ("#password"). Val (p);
$ (' #cookiePwd '). Click (function () {
if ($ (this). attr (' checked ')) {
$ (' #cookieInfo '). attr (' checked ', true);
}
});
$ ("#btn"). Click (function () {
var n = $ ("#username"). Val (). Trim ();
var p = $ ("#password"). Val (). Trim ();
if ($ (' #cookiePwd '). attr (' checked ')) {
$.cookie (' username ', n, {expires:7});
$.cookie (' Password ', p, {expires:7});
}else{
$.cookie (' username ', null);
$.cookie (' password ', null);
}
});
});
</script>

<div class= "Login-wrapper" >
<div class= "Login-area dib-m" >
<form action= "login.do" method= "post" id= "Name=" "class=" form ">
<div id= ' btn_warning ' class= "Bug-text" style= "Display:none;" ></div>
<div class= "user textbox" ><input type= "text" id= "username" name= "username" value= "" placeholder= "Please enter user name" > </div>
<div id= ' user_warning ' class= "Bug-text" ></div>
<div class= "pass textbox" ><input type= "password" id= "password" name= "password" value= "" placeholder= "Please enter password" ></div>
<div id= ' pass_warning ' class= "Bug-text" ></div>
<div class= "BTN" >
<input type= "button" class= "login-btn dib-m" id= "btn" value= "Login" >
<label class= "Dib-m" >
<em class= "C9" > Remember password </em>
<input type= "checkbox" Checked class= "checkbox checkbox-animbg dib-m" id= "Cookiepwd" ></label>
</div>
</form>
</div>
<div class= "Dib-m h" ></div>
</div>

Java implementation application remembers user name, password function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.