0
votes

I'm trying to enable a success message after the form is complete using Mailerlite script.

How can I access variables inside a script to be able to show the success message?

ml_webform_success_983964() this function works with onClick although it won't validate the field and just show the message. So maybe I need to access the script.

Someone please help me i have no idea what I'm doing lol

useEffect(() => {
    const script = document.createElement("script");

    script.src =
      "https://groot.mailerlite.com/js/w/webforms.min.js?vaa2c3c2aced59c19bcfc4be08835b7b3";
    script.async = true;

    document.body.appendChild(script);

    return () => {
      document.body.removeChild(script);
    };
  }, []);

  function ml_webform_success_983964() {
    var $ = ml_jQuery || jQuery;
    $(".ml-subscribe-form-983964 .row-success").show();
    $(".ml-subscribe-form-983964 .row-form").hide();
  }