Repository navigation
Expand file tree
/
Copy pathfile-upload-with-forms.js
More file actions
59 lines (59 loc) · 2.04 KB
/
Copy pathfile-upload-with-forms.js
File metadata and controls
59 lines (59 loc) · 2.04 KB
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
this.default = function () {
ej.base.enableRipple(true);
var uploadObj = new ej.inputs.Uploader({
autoUpload: false,
multiple: false,
allowedExtensions: 'image/*',
selected: onFileSelect
});
uploadObj.appendTo('#fileupload');
document.getElementById('browse').onclick = function () {
document.getElementsByClassName('e-file-select-wrap')[0].querySelector('button').click();
return false;
};
function onFileSelect(args) {
var inputElement = document.getElementById('upload');
inputElement.value = args.filesData[0].name;
}
var options = {
customPlacement: function (inputElement, errorElement) {
inputElement = inputElement.closest('.form-group').querySelector('.error');
inputElement.parentElement.appendChild(errorElement);
},
rules: {
'name': {
required: true
},
'email': {
required: true
},
'upload': {
required: true
}
}
};
var formObj = new ej.inputs.FormValidator('#form1', options);
function onFormSubmit() {
var formStatus = formObj.validate();
if (formStatus) {
formObj.element.reset();
confirm.show();
}
}
var confirm = new ej.popups.Dialog({
width: '335px',
visible: false,
header: 'Success',
content: 'Your details have been updated successfully, Thank you.',
target: document.getElementById('control_wrapper'),
showCloseIcon: true,
isModal: true,
animationSettings: {
effect: 'Zoom'
}
});
confirm.appendTo('#confirmationDialog');
document.getElementById('submit-btn').onclick = function () {
onFormSubmit();
};
};