2
votes

Referring to the Angular docs for ngForm directive:

If a form has only one input field then hitting enter in this field triggers form submit (ngSubmit)

if a form has has 2+ input fields and no buttons or input[type=submit] then hitting enter doesn't trigger submit

if a form has one or more input fields and one or more buttons or input[type=submit] then hitting enter in any of the input fields will trigger the click handler on the first button or input[type=submit] (ngClick) and a submit handler on the enclosing form (ngSubmit)

In my form, I have a Bootstrap button-radio followed by a button[type=submit] However, when one presses the 'enter' key from within an input box, the first "button-radio" gets clicked instead of the button[type=submit]

I know, as per the doc this is supposed to happen (first button or input[type=submit]), but is there any way to change this behaviour?

1
Could you post a code example?leepowell
I'm not being able to reproduce this on Plunker. But it's happening in my app. Wonder what's the difference... Strange!Saurabh Nanda

1 Answers

0
votes

How about putting a hidden button on top of the form which has binding to do the submit?