When a user is filling in a form and inadvertently clicks on a link to another page, or clicks the back button, it sends the browser to a new page and discards all user input. In the event that the form is large and complex, this can represent a significant lost effort.
In this recipe, we will create a Visualforce page that allows a user to create a contact record. If the user clicks on a button to save the record or cancel the creation, they will be requested to confirm that they wish to continue with the action. If the user clicks on the Save or Cancel button, this will submit the form without further confirmation.
This recipe uses the jQuery (http://jquery.com/) JavaScript framework to swap the buttons. The JavaScript file is included from the Google Hosted Libraries' content delivery network rather than being uploaded as a Salesforce static resource, as this makes it straightforward to move to new versions simply by changing the URL of the included...