Closed
Description
Discussed in https://github.com/bootstrap-vue/bootstrap-vue-next/discussions/877
Originally posted by loetermann January 14, 2023
Hi,
so I have a with a sumbit button. Some input fields are required. I would like to also submit the form when the user presses Ctrl+S. I would like the to do the same input validation the submit button triggers.
Is there any way to get this done? I fear not, as the Components do not defineExpose their functions, right?
<script setup lang="ts">
const inputForm = ref(null);
function onKeyDown(e: KeyboardEvent) {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
onSave(); // <-- This does no validate if the required fields are filled
inputForm.value?.submit() // <-- This function does not exist. Any other option to trigger the sumbit here?
}
}
</script>
<template>
<b-form ref="inputForm" @submit="onSave">...</b-form>
</template>
```</div>