Using Ajax to submit the form

After clicking the Submit button, all fields will be validated automatically if the SubmitButton plugin is enabled. Usually you have two choices in the case all fields pass their validations:

  • Submit the form to the server. It can be done via the DefaultSubmit plugin
  • Send the form data to server via an Ajax request.

For the second scenario, you can handle the core.form.valid event as following

The sample code above uses a built in method FormValidation.utils.fetch(url, options) to send data to given url. It's up to you to choose your favourite library for doing the same thing, such as axios:

More examples