I really have the enter key mapped to Cancel button, I can see at the load of the HTML page where the Cancel button is circled compared to the SignIn button!

The button may be focused when the page loads, but I imagine you must enter some data into input fields, dropdowns, or some other input. To enter the data, you by definition are removing the focus from the button that initially had focus.


For example:

Page loads, and cancel button has focus.
Click on a textfield and type in data, changes focus to the text field.
Pressing enter then simply submits the form, since focus is on a text field.
Every browser I've tried does this by pressing the first button in the form, which results in the listener from the first submit button being called.


Not sure but I think if you press enter in an HTML form the form action listener will be called as opposed to the individual button action listeners (correct me if I'm wrong). So just try to define the 'listener' parameter in you @Form element

The 'Enter' key isn't doing anything magic.. I "THINK" it's just a browser shortcut pressing a button, not specifically for submitting a form. All it's doing is pressing a button for you, which is usually submit button but doesn't have to be.


Way back in the day netscape didn't submit a form when you pressed Enter unless there was only one text field in the form. And way back when I remember I had to remove the submit buttons altogether and just use normal buttons with onclick listeners that set form fields and called form.submit in javascript.

I'm probably completely off on what you mean, but I've generally needed to place whatever button I wanted mapped to 'Enter' first on the page.
Not ideal, but it works. If you have to have something else there may be a way to detect the 'Enter' key in javascript, but I'm no JS guru. Of course at that point you're likely in custom component territory.


Hope that's helpful, and at least mostly accurate.

-Ryan Owens




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to