-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcollect.js
More file actions
40 lines (37 loc) · 1.04 KB
/
collect.js
File metadata and controls
40 lines (37 loc) · 1.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
// get YOUR_VAULT_TENANT in the VGS Dashboard -> Home -> under the page header -> Vault ID
const vgsForm = window.VGSCollect.create('YOUR_VAULT_ID', 'SANDBOX', () => {});
const css = {
boxSizing: 'border-box',
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI"',
color: '#40545F',
fontSize: '1rem',
};
vgsForm.field('#secure-field', {
type: 'text',
name: 'secure-field',
css: css,
});
document.getElementById("collect-form").addEventListener("submit", async(e) => {
e.preventDefault();
vgsForm.submit(
"/", // change in VGS Dashboard -> Routes -> Manage (inbound route) -> Filters -> Conditions
{
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",
data: {
"form-name": "collect-form",
"field": document.querySelector("input#field").value
},
serialization: "formData"
},
(status, state) => {
console.log('state', state);
window.location.reload();
},
function(errors) {
console.error(errors);
}
);
});