Don't submit form on "enter"

Is it possible to stop submitting a form when pressing "enter" ?
10 Replies
JJSanders
JJSandersOP10mo ago
Does anyone have an Idea on how to do this ?
dhanar98
dhanar9810mo ago
protected function mutateFormDataBeforeCreate(array $data): array
{

}
protected function mutateFormDataBeforeCreate(array $data): array
{

}
for this function check the key bindings if the enter button is triggered
JJSanders
JJSandersOP10mo ago
Do you have a more concrete exemple how this will look?
Matthew
Matthew10mo ago
I believe:
public function create(bool $another = false): void
{
}
public function create(bool $another = false): void
{
}
In your Create Record This overwrites the create method
JJSanders
JJSandersOP10mo ago
How can you then prevent "enter" to submit in this code?
Matthew
Matthew10mo ago
Oh wait wdym "enter"?
JJSanders
JJSandersOP10mo ago
I want to prevent that pressing "enter" submits the form
Matthew
Matthew10mo ago
weird, when I press enter, form doesnt submit It could be a JS thing no idee
awcodes
awcodes10mo ago
Um. This is actually how forms work at the browser level. If an input other that select is focused then pressing enter will submit the form. I would also highly recommend against trying to prevent the behavior as doing so would result in accessibility issues since it is the expected behavior.
JJSanders
JJSandersOP10mo ago
I know. But some users don't know how browsers work. So maybe I should just tell them that this is the way it works in browsers.
Want results from more Discord servers?
Add your server