{"id":1374,"date":"2024-06-13T09:15:40","date_gmt":"2024-06-13T07:15:40","guid":{"rendered":"https:\/\/wypo.io\/documentations\/%taxomony%\/formmaster\/evenements-javascript\/"},"modified":"2024-06-20T21:08:32","modified_gmt":"2024-06-20T19:08:32","slug":"javascript-events","status":"publish","type":"wypo_documentations","link":"https:\/\/wypo.io\/en\/documentations\/formmaster\/javascript-events\/","title":{"rendered":"Javascript events"},"content":{"rendered":"\n<p class=\"\">The <strong>FormMaster<\/strong> plugin triggers several JavaScript events when a form is submitted. These events allow developers to react to different stages in the form submission process. This documentation lists the events available and provides examples of their use.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-smallbordertop   hf_animated fade_bottom default is-layout-constrained wp-block-group-is-layout-constrained\" style=\"margin-top:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--50)\">\n<h2 class=\"wp-block-heading   \" datalink=\"content-triggered-events\">Triggered events<\/h2>\n\n\n\n<h3 class=\"wp-block-heading   \" datalink=\"content-formmaster_submit\">formmaster_submit<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><strong>Description<\/strong>: This event is triggered as soon as the form is submitted.<\/li>\n\n\n\n<li class=\"\"><strong>Event details<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"\"><code>formID<\/code>: The ID of the submitted form.<\/li>\n\n\n\n<li class=\"\"><code>fields<\/code>: The list of fields sent.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading   \" datalink=\"content-formmaster_failed\">formmaster_failed<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><strong>Description<\/strong>: This event is triggered if the form submission fails.<\/li>\n\n\n\n<li class=\"\"><strong>Event details<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"\"><code>formID<\/code>: The ID of the submitted form.<\/li>\n\n\n\n<li class=\"\"><code>fields<\/code>: The list of fields sent.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading   \" datalink=\"content-formmaster_sent\">formmaster_sent<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><strong>Description<\/strong>: This event is triggered if the form is successfully sent.<\/li>\n\n\n\n<li class=\"\"><strong>Event details<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"\"><code>formID<\/code>: The ID of the submitted form.<\/li>\n\n\n\n<li class=\"\"><code>fields<\/code>: The list of fields sent.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-style-smallbordertop   hf_animated fade_bottom default is-layout-constrained wp-block-group-is-layout-constrained\" style=\"margin-top:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--50)\">\n<h2 class=\"wp-block-heading   \" datalink=\"content-examples-of-use\">Examples of use<\/h2>\n\n\n\n<h3 class=\"wp-block-heading   \" datalink=\"content-display-an-alert-when-sending-is-successful\">Display an alert when sending is successful<\/h3>\n\n\n    <div class=\"wp-block-habefast-code  \">\n      <header class=\"habefast-code-header\">\n        <div class=\"habefast-code-lang is-lang-js\">\n          JS        <\/div>\n      <\/header>\n      <textarea\n        class=\"habefast-code-source\"\n        name=\"codemirror-1673950886\"\n        id=\"codemirror-1673950886\"\n      >document.addEventListener(&quot;formmaster_sent&quot;, function (event) {\n\tconst formID = event.detail.formID;\n    const fields = event.detail.fields;\n\n\t\/\/ Check if a specific field (e.g., email) is present and not empty\n    if (fields.has(&quot;your-email&quot;) &amp;&amp; fields.get(&quot;your-email&quot;).trim() !== &quot;&quot;) {\n    \talert(&quot;Envoi r\u00e9ussi avec email : &quot; + fields.get(&quot;your-email&quot;));\n\t}\n});<\/textarea>\n      <script>\n        CodeMirror.fromTextArea( document.getElementById('codemirror-1673950886'), {\n          mode: 'javascript',\n          readOnly: true,\n          lineNumbers: true,\n          firstLineNumber: 1,\n          matchBrackets: true,\n          indentUnit: 4,\n          tabSize: 4,\n          lineWrapping: true,\n        } );\n      <\/script>\n    <\/div>\n    \n\n\n<h3 class=\"wp-block-heading   \" datalink=\"content-display-form-id-when-submission-fails\">Display form ID when submission fails<\/h3>\n\n\n    <div class=\"wp-block-habefast-code  \">\n      <header class=\"habefast-code-header\">\n        <div class=\"habefast-code-lang is-lang-js\">\n          JS        <\/div>\n      <\/header>\n      <textarea\n        class=\"habefast-code-source\"\n        name=\"codemirror-113459563\"\n        id=\"codemirror-113459563\"\n      >document.addEventListener(&quot;formmaster_failed&quot;, function (event) {\n    const formID = event.detail.formID;\n    const fields = event.detail.fields;\n\talert(&quot;mail &quot;+formID+&quot; failed&quot;);\n});<\/textarea>\n      <script>\n        CodeMirror.fromTextArea( document.getElementById('codemirror-113459563'), {\n          mode: 'javascript',\n          readOnly: true,\n          lineNumbers: true,\n          firstLineNumber: 1,\n          matchBrackets: true,\n          indentUnit: 4,\n          tabSize: 4,\n          lineWrapping: true,\n        } );\n      <\/script>\n    <\/div>\n    <\/div>\n","protected":false},"featured_media":0,"parent":1366,"menu_order":18,"template":"","meta":{"_habefastfse_class":"","hf_wpseo_meta_title":"JavaScript events documentation for FormMaster","hf_wpseo_meta_description":"Discover the complete documentation for JavaScript events triggered by the FormMaster plugin. Learn how to use JavaScript events with practical examples and conditions on sent fields.","hf_wpseo_meta_robots_index":"","hf_wpseo_meta_robots_follow":true,"hf_wpseo_meta_robots_advanced":"{}","hf_wpseo_meta_canonical_url":"","documentation_description":"","documentation_menu_text":"","documentation_related_pageid":0,"wypo_hidden_role_wypo_users_not_logged":false,"wypo_visibility_role_wypo_users_not_logged":false,"wypo_hidden_role_administrator":false,"wypo_visibility_role_administrator":false,"wypo_hidden_role_habefast":false,"wypo_visibility_role_habefast":false,"wypo_hidden_role_customer":false,"wypo_visibility_role_customer":false,"wypo_hidden_role_habefast_manager":false,"wypo_visibility_role_habefast_manager":false,"wypo_hidden_for_role":false,"wypo_visibility_for_role":false},"class_list":["post-1374","wypo_documentations","type-wypo_documentations","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/wypo.io\/en\/wp-json\/wp\/v2\/wypo_documentations\/1374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wypo.io\/en\/wp-json\/wp\/v2\/wypo_documentations"}],"about":[{"href":"https:\/\/wypo.io\/en\/wp-json\/wp\/v2\/types\/wypo_documentations"}],"up":[{"embeddable":true,"href":"https:\/\/wypo.io\/en\/wp-json\/wp\/v2\/wypo_documentations\/1366"}],"wp:attachment":[{"href":"https:\/\/wypo.io\/en\/wp-json\/wp\/v2\/media?parent=1374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}