/
config.js
executable file
·75 lines (74 loc) · 6.74 KB
/
config.js
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
let cfg = {
"disableValidations": false, // will not attach to window if true (can be passed in user-set options too)
"formValidateAttr": "data-jsv-form", // the data attribute to look for which triggers validation
"formIsValid": "data-jsv-form-isvalid", // data attribute store on <form> element when form is valid
"disableIcons": "data-jsv-disable-icons", // data attribute that means no valid/invalid icons shouldappear on any of this form's fields
"formValidCallback": "data-jsv-form-valid-callback", // data attribute on form element that contains a window function to call when form validates (for all events EXCEPT submit) !!! DON'T USE AS A SUBMIT HANDLER !!!
"formInvalidCallback": "data-jsv-form-invalid-callback", // data attribute on form element that contains a window function to call when form is invalid - only called AFTER submit (fails)
"disableInvalid": "data-jsv-disable-invalid", // disables form/button until form is validated
"fieldValidators": "data-jsv-validators", // the data attribute containing the validators to apply to field (field level, comma-separated)
"fieldIsValid": "data-jsv-field-isvalid", // data attribute store on field element when valid
"prevVal": "data-jsv-field-prev-val", // data attribute denoting the field has been touched
"lenMin": "data-jsv-min", //data attribute denoting min allowed length of field
"lenMax": "data-jsv-max", //data attribute denoting max allowed length of field
"lenExact": "data-jsv-exact", //data attribute denoting field must be this length exactly
"minThresh": "data-jsv-min-selected", //data attribute denoting how many fields must be selected (for multi-option inputs like checkboxes)
"fieldCompare": "data-jsv-compare", //data attribute, the value of which is the NAME of the field it must match
"fieldPattern": "data-jsv-pattern", //data attribute containing regular expression to evaluate the field value against
"ajaxEndpoint": "data-jsv-ajax-endpoint", //data attribute containing endpoint for ajax validator
"ajaxKey": "data-jsv-ajax-key", //data attribute containing the key to look for in ajax result (json)
"ajaxValue": "data-jsv-ajax-value", //data attribute containing the value in ajax endpoint to validate against
"ajaxProcessing": "data-jsv-ajax-processing", //data attribute containing the message you want to appear during processing
"fieldContains": "data-jsv-contains", //data attribute containing the word that must be contained in the entered string
"expireDate": "data-jsv-expiredate", //data attribute containing one of "year", "month", "day" for expiredate validator
"dependentFields": "data-jsv-dependents", // data attribute containing comma-delim list of field (names) that need to validate before current
"fieldDebounce": "data-jsv-debounce", //data attribute containing an integer representing the debounce rate in ms
"invErrPrefix": "data-jsv-field-error-", //data attribute, if populated (in the field element) this message overrides the default when field is invalid. the suffix is validator name
"fieldInvalidCallback": "data-jsv-field-invalid-callback-", //data attribute, if populated (in the field element) this callback function will be called on invalid. suffix is validator name
"fieldValidCallback": "data-jsv-field-valid-callback-", //data attribute, if populated (in the field element) this callback function will be called on valid. suffix is validator name
"valTarget": "data-jsv-validation-target", //data attribute, contains an id (selector). if exists the UI validation indicators will be targeted to this container. otherwise this is creted & assigned
"invMessage": "data-jsv-message-target", //data attribute, contains an id (selector). if exists field-level error messages will be targeted to this container. otherwise this is creted & assigned
"disableIcon": "data-jsv-disable-icon", // data attribute on a field denoting valid/invalid icons should not be shown
"fieldValid": "form-field-valid", //class name denoting the field has been validated (for field wrapper)
"validIcon": "form-field-valid-focusout", //class name denoting the field is valid, inserted AFTER focusout
"fieldInvalid": "form-field-invalid", //class name denoting the field is not valid (for field wrapper)
"invIcon": "form-field-invalid-focusout", //class name denoting the field is not valid, inserted AFTER focusout
"fieldContainer": {
"className": "validate-input", // class name of element that needs to wrap every field to be validated
"addClasses": [], // ARRAY additional classes to add to field container
},
"formError": {
"className": "validate-form-error-message", // form-level error container class name
"addClasses": ['well', 'validate-form-hidden-message'], // ARRAY additional classes to add to form error container
},
"formSuccess": {
"className": "validate-form-success-message", // form-level error container class name
"addClasses": ['well', 'validate-form-hidden-message'] // ARRAY additional classes to add to form success container
},
"fieldError": {
"className": "validate-field-error-message", // field-level error container class name
"addClasses": [], // ARRAY additional classes to add to field error container
},
"baseId": "data-jsv-base-id", // a random id assigned to each field that will be used to create selector IDs for associated elements (error, validation container)
"messageHidden": "validate-form-hidden-message", // classname that toggles visibility onform-level message container(s)
"buttonSuccess": "success-button", // class name added to <button> element after successful submit (like if you want to change it green)
"buttonTooltip": "data-jsv-form-tooltip", // data attribute for button tooltip
"buttonOriginalText": "data-original-text", // data attribute that stores original text of <button> element (ex: if swapped with "sending..." during submit)
"formIncompleteText": "data-jsv-form-incomplete-tooltip", // data attribute on <form> that stores the text to be shown in tooltip when form is in invalid state
"formInvalidMessage": "data-jsv-form-invalid-message", // data attribute on <form> that stores the text to be shown in in error container when form submitted is invalid
"safeStringInput": true, // passes any entered field values thru a santiizer
"safeEndpoints": false, // if true endpoints can only be relative urls (i.e. no http://)
"ajaxTimeout": 8000, // milliseconds
"debounceDefault": 300, // milliseconds
"useCss": true,
"useTooltip": true,
"isValidColor": "#13bd3a",
"isInvalidColor": "#ff0000",
"isValidIcon": "\\2713",
"isInvalidIcon": "\\2716",
"fieldErrorFont": "normal 12px Helvetica, Arial, sans-serif",
"formShowMessages": true,
"formSubmitHandler": "data-jsv-submit-handler",
"formIncompleteMessage": "Please complete all required fields" // default text to show when formIncompleteText is not specified in <form>
};
export default cfg;