AutoComplete submits the TemplateForm on key Enter


I have an AutoComplete control inside a TemplateForm with a regular setup we see all over in the samples.
Today I noticed that when I press enter in AutoComplete, it does submit the form. And yes, I don't want to, because I also have a Submit button that should be used for that purpose.
I don't see anything obvious in the API docs: Class RadzenAutoComplete

Any suggestions for how to turn this default behavior off or work around it?


Yes, that's correct. It happens for all input controls.
Then the solution would be no implicit submit button. I forgot about this HTML feature. :slight_smile:
But it requires to js interop call the form.submit() programmatically, then handle the submit event on the form and prevent the default behavior, then interop callback into blazor TemplateForm to do the validation and eventually call the Submit callback handler. Uh oh, a lot of work.

If submit button is a must then include this in the RadzenAutoComplete:

onkeydown="return event.keyCode !== 13"

This is plain JS, no @ symbol.

1 Like