-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformkeeper.html
83 lines (70 loc) · 2.73 KB
/
formkeeper.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FormKeeper Demo</title>
<link rel="stylesheet" href="css/asdui1.4b.css" type="text/css" media="all" />
</head>
<body>
<form id="form" data-formid="aaa">
<label>姓名:<input type="text" name="name"></label><br>
性别:<label><input type="radio" name="gender" value="男"> 男</label><label><input type="radio" name="gender" value="女"> 女</label><br>
订阅类型:<label><input type="checkbox" name="subs[]" value="新闻">新闻</label><label><input type="checkbox" name="subs[]" value="娱乐">娱乐</label><label><input type="checkbox" name="subs[]" value="购物">购物</label><br>
<label>时间:<input type="date" name="date"></label><br>
<label>方式:<select name="type" multiple><option>E-mail</option><option value="sms">短信</option><option>站内信</option></select></label><br>
<label>频率:<select name="fren"><option value="">请选择</option><option value="daily">每天</option><option value="weekly">每周</option><option value="monthly">每月</option></select></label><br>
<label>简介:<textarea name="note" rows="4"></textarea></label><br>
<br><button type="submit">提交</button>
<button type="button" id="getData">获取本地数据</button>
<button type="button" id="backup">备份表单</button>
<button type="button" id="restore">还原表单</button>
<button type="button" id="clear">清除备份数据</button>
</form>
<script src="js/jquery1.91.min.js"></script>
<script src="js/asdui.js"></script>
<script>
var Box = new ZUI.Box();
var formStroe = new ZUI.FormKeeper('form',{
restoreAtInit: true,
clearOnSubmit: true,
onInit:function(fm,data){
var arr = $.object.values(data);
var a = jQuery.grep(arr, function(n, i){
return n !=''&& n !=null;
//return (n != 5 && i > 4);
});
console.log(arr);
if(a.length>0){
Box.confirm('您上次退出有未提交的表单数据,是否恢复?',{
boxtitle:'系统提示',
textBoxBtnOk: '恢 复',
textBoxBtnCancel: '不恢复',
onShow:function(a,b,c,d,e){
//console.log(a);console.log(b);console.log(c);console.log(d);console.log(e)
},
callback:function(){
formStroe.backup();
},
onCancle:function(){
}
});
}
}
});
$(function () {
//$('#getData').on('click', function () {
// console.log(formStroe.backupData());
// });
$('#restore').on('click', function () {
formStroe.restore();
});
$('#clear').on('click', function () {
formStroe.clear();
});
$('#backup').on('click', function () {
formStroe.backup();
});
});
</script>
</body>
</html>