Stop form submit when using scanner

My app uses an external QR scanner to read some codes. Everything is working correctly. However, everytime the scanner reads something the form is submitting which is not something I want to happen. Field should only display the value and thats it. Anyways I can control this behaviour
Solution:
you could try something like this? ```php TextInput::make('qr_code') ->label('Scan QR Code')...
Jump to solution
4 Replies
Sjoerd24
Sjoerd243mo ago
Thats because most QR scanners scan the code and then automaticly follow that with an "enter". You would have to prevent that action from happening, either change it in your scanner or catch it in the code.
Will Aguilar
Will AguilarOP3mo ago
Yeah that’s what I want to figure out 😬 how to catch it or disable that automatic enter in scan reads.
Solution
rhysleesdev
rhysleesdev3mo ago
you could try something like this?
TextInput::make('qr_code')
->label('Scan QR Code')
->autofocus()
->extraAttributes([
'x-on:keydown.enter.prevent' => '',
])
TextInput::make('qr_code')
->label('Scan QR Code')
->autofocus()
->extraAttributes([
'x-on:keydown.enter.prevent' => '',
])
Will Aguilar
Will AguilarOP3mo ago
Thank you for tacking the time to answer. This work perfectly 🙂

Did you find this page helpful?