Pressing Enter to submit

When the Enter key is pressed and a single-line HTML form element has focus, modern browsers will submit the form via the first submit button. If the user has pressed the Enter key expecting to move on to a new line and remain in the input element, this can lead to the submission of a partially filled in form, resulting in a low-quality record being created.

In this recipe, we will create a Visualforce page that allows a user to create an opportunity. If the user presses the Enter key while filling in any of the opportunity fields, they will be asked to confirm that they wish to submit the form.

Getting ready

This recipe makes use of a standard controller, so we only need to create the Visualforce page.

How to do it...

  1. Create ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.