25 lines
681 B
JavaScript
25 lines
681 B
JavaScript
export default {
|
|
methods: {
|
|
onSubmit() {
|
|
/** DO NOT REMOVE;
|
|
* Needed to prevent default form submit behavior.
|
|
* Cannot use .prevent modifier for vee-validate Form.
|
|
*/
|
|
},
|
|
onInvalidSubmit({ errors }) {
|
|
/**
|
|
* Identify the first error field and put focus on it
|
|
* get error names array
|
|
*/
|
|
const errorNames = errors ? Object.keys(errors) : [];
|
|
const firstErrorEl = errorNames[0];
|
|
if (firstErrorEl) {
|
|
const qsString = `[data-focus-target="${firstErrorEl}"]`;
|
|
const el = document.querySelector(qsString);
|
|
if (el !== null) {
|
|
el.focus();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
};
|