-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
79 lines (73 loc) · 2.81 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.5/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.5/css/dx.light.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn3.devexpress.com/jslib/19.2.5/js/dx.all.js"></script>
<style type="text/css">
#formAvatar {
height: 128px;
width: 128px;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
var employee = {
ID: 1,
FirstName: "Peter",
LastName: "Smith",
Photo: "images/petersmith.png"
};
$("#form").dxForm({
validationGroup: "formGroup",
formData: employee,
items: [{
dataField: "FirstName"
}, {
dataField: "LastName",
isRequired: true,
template: function (data, itemElement) {
$("<div>").dxTextBox({
value: employee.LastName,
onValueChanged: function (e) {
data.component.updateData(data.dataField, e.value);
}
}).dxValidator({
validationGroup: "formGroup",
validationRules: [{
type: "required",
message: "LastName is required"
}]
}).appendTo(itemElement);
}
}, {
dataField: "Photo",
template: function (data, itemElement) {
$("<img>").attr({
id: "formAvatar",
src: employee.Photo
}).appendTo(itemElement);
}
}, {
itemType: "button",
horizontalAlignment: "left",
buttonOptions: {
text: "Validate",
type: "success",
onClick: function (e) {
var validationResult = DevExpress.validationEngine.validateGroup("formGroup");
if (!validationResult.isValid)
alert("dxForm is invalid");
}
}
}]
});
});
</script>
</head>
<body>
<div id="form"></div>
</body>
</html>