• WPCF7 Team, good night!

    I’ve been trying to make some customizations to the form and fields during the submission process and I saw that all DOM Events are triggered only after the AJAX call. I would like to propose a change of flow, in order to add or change some events:

    1. wpcf7submit: fired at the beginning of the process, as soon as the submit button is pressed

    2. wpcf7submiterror: triggered if there was a validation error, which would prevent the AJAX call

    3. wpcf7submited: the AJAX call was made and the data sent to the backend, regardless of the result

    Along with wpcf7submited the other events (wpcf7invalid, wpcf7spam, wpcf7mailsent and wpcf7mailfailed) would be triggered according to each result of the email sending process.

    It would also be nice to have a wpcf7mailskiped event, in cases where the skip_mail attribute is active.

    I would be very happy to see events like these available in the next versions.

    Best regards,

    Raphael Ramos

Viewing 1 replies (of 1 total)
  • 1. This exists, it’s the native ‘submit’ event that will be triggered by the form element https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event

    2 and 3. validation happens server side, hence the AJAX request is sent anyway, you will need to check the response, the request will return a JSON object like this:

    {"into":"#wpcf7-f242-p243-o2","status":"validation_failed","message":"One or more fields have an error. Please check and try again.","posted_data_hash":"","invalid_fields":[{"into":"span.wpcf7-form-control-wrap.your-name","message":"The field is required.","idref":null},{"into":"span.wpcf7-form-control-wrap.your-email","message":"The field is required.","idref":null}]}

Viewing 1 replies (of 1 total)
  • The topic ‘DOM Events Review’ is closed to new replies.