I have a form that is pre-filled with data from a MySQL database entry. When the form is submitted, I need to validate if any of the 15 field values in the form have been changed. If there are changes, I want to trigger a PHP script to update the database entry and then load the main page content into my div (redirection will be handled by the PHP script). If no changes were made, I simply want to load the main page content directly into my div.
My question is, what would be considered best practice: performing the validation on form unload, or including the validation check within the ajax function that calls the appropriate script based on the result?