39,087
社区成员
发帖
与我相关
我的任务
分享
appcan.ready(function(){
var username = appcan.locStorage.getVal('username');
var userpwd = appcan.locStorage.getVal('userpwd');
if(username !== null && userpwd !== null){
$('input[name="user"]').val(username);
$('input[name="password"]').val(userpwd);
<!--document.getElementById('user').value=username;
document.getElementById('password').value=userpwd;-->
}else{
<!--$('input[name="user"]')[0].focus();-->
alert("no data");
}
});
$('input[name="sub"]').click(function(){
alert("here");
if($('input[name="rememberMe"]:checked').val=='on'){
var username = $('input[name="user"]').val();
var userpwd = $('input[name="password"]').val();
appcan.locStorage.setVal('username',username);
appcan.locStorage.setVal('userpwd',userpwd);
}
alert("保存失败!");
});
form表单:
<form id="login" name="login" action="login.php" method="post"> <!-- onsubmit="" -->
<table>
<tr>
<td>
<input name="user" type="text" id="user" placeholder="会员名"/>
</td>
</tr>
<tr>
<td>
<input type="password" name="password" id="password" placeholder="密码"/>
</td>
</tr>
<tr>
<td>
<input type="text" maxlength="4" name="randcode" id="randcode" placeholder="验证码" />
<img onclick="get_randfunc(this);" src='<{$config.weburl}>/includes/rand_func.php'/>
</td>
</tr>
<!-- 添加选择记住用户密码,自动登录 -->
<tr>
<td>
<input type="checkbox" name="rememberMe" id="rememberMe"/>
<label for="rememberMe">下次自动登录</label>
<a href="#">忘记密码?</a>
</td>
</tr>
<tr>
<td>
<input name="action" type="hidden" value="submit" />
<input name="forward" type="hidden" id="forward" value="<{$smarty.get.forward}>" />
<input type="submit" value="登录" onclick="return do_login();" name="sub">
</td>
</tr>
</table>
为什么没有localstorage的值呢?