您好,登錄后才能下訂單哦!
話不多說(shuō),請(qǐng)看代碼:
<script type="text/javascript"> $(document).ready(function () { $("#UserAccount").focus(); //記住用戶名和密碼 $('#remebers').click(function () { if ($("#UserAccount").val() == "") { alert("用戶名不能為空!"); } if($("#UserPassword").val() == "") { alert("密碼不能為空!"); } else { if ($('#remebers').attr("checked")) { setCookie("uname", $("#UserAccount").val(), 60); setCookie("upwd", $("#UserPassword").val(), 60); } else { delCookie("uname"); delCookie("upwd"); } } }); if (getCookie("uname") != null) { $('#remebers').attr("checked", "checked"); $('#UserAccount').val(getCookie("uname")); $('#UserPassword').val(getCookie("upwd")); } }) //寫cookies function setCookie(name, value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); } //讀取cookies function getCookie(name) { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return unescape(arr[2]); else return null; } //刪除cookies function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = getCookie(name); if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); } </script> <div class="main"> <section id="login_form"> @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post)) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <table> <tr> <td align="right">賬 號(hào):</td> <td align="left"><input type="text" id="UserAccount" name="UserAccount" /> @Html.ValidationMessageFor(m => m.UserAccount)</td> </tr> <tr> <td align="right">密 碼:</td> <td align="left"> <input type="password" id="UserPassword" name="UserPassword" /> @Html.ValidationMessageFor(m => m.UserPassword) </td> </tr> <tr> <td></td> <td align="left"> <input name="remebers" id="remebers" type="checkbox" /> <span >記住用戶名和密碼</span> </td> </tr> <tr> <td></td> <td align="left"> <input type="submit" name="submit" id="submit" value="" /> <input type="reset" name="reset" id="reset" value="" /> </td> </tr> </table> } </section> <div class="note"> * 不要在公共場(chǎng)合保存登錄信息;<br /> * 為了保證您的帳號(hào)安全,退出系統(tǒng)時(shí)請(qǐng)注銷登錄 <span id="msg_tip"></span> </div> </div>
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持億速云!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。