Kenny
Kenny

Reputation: 2144

Angular Form Reactive Approach - Disable Submission via Enter Key (Ionic App)

I've searched the web extensively for this but cannot find a solution. I have an Ionic app with a page that has a reactive Angular form. I'm only testing on the browser right now, and when I hit enter on that page, it activates my onSubmit() method.

Is it possible to disable the enter key from submitting the form?

<form [formGroup]="movieListForm" (ngSubmit)="onSubmit()">
</form>

Upvotes: 0

Views: 587

Answers (1)

DeborahK
DeborahK

Reputation: 60518

You could try something like this:

<form (keydown.enter)="$event.preventDefault()"></form>

Upvotes: 2

Related Questions