Q:

Where to do checks on form submit for redirection: onunload or in ajax function?

I've got this form, initialized from the data in a  Mysql database entry. If the form is submitted, I want to check if the values (15 of them) in the form have been changed, I want to call a php script to update the database entry and then load the main page content in my div (redirection would be done in the php script). If no change was made, I want to directly  load the main page content in my div.
My question is the following, what would be the best practice: doing the checks on unload of the form, or putting the check in the ajax function that would call the correct script in function of the check?

A:

From your explanation, you said you are checking for change. If the form validations are simple ( data input error, checking for range, checking for change etc) it would be better to put it as javascript. So, you will have your code along with ajax function. 
In your case, you will submit the data through ajax if the form is valid. Otherwise just load the content into div

