I had a Drupal project where I need to submit a form without reloading the page so I used Form API #ajax parameter to execute my custom callback function and validate the form.
Sample FORM: