ExactSales表格,带有感谢信息的电子邮件验证

时间:2018-11-05 13:54:47

标签: javascript jquery html

我有一个带有此ExactSales表单的登录页面,我需要一个脚本来验证电子邮件。

这是我的代码:

HTML;

<div id="btnsucess"><p>Obrigado!</p></div>
<div id="formhide">
                <form action="https://ws.inversapub.com/subscribe" id="myform" name="myForm" onsubmit="return validateForm()" data-validate="https://lp.inversapub.com/wp/wp-admin/admin-ajax.php" method="POST" target="hiddenFrame" class="subscribe-form" data-page-id="115" _lpchecked="1">
                  <input name="emailAddress" type="email" required="" oninput="this.setCustomValidity('')" oninvalid="this.setCustomValidity('Preencha um endereço de e-mail válido.')" placeholder="Coloque aqui seu e-mail" class="input-email"  />
<div class="alert alert-warning alert-invalid-email" style="display: none;">Por favor, insira um e-mail <strong>válido</strong>.</div>
                   <input type="submit" value="QUERO ME INSCREVER" class="btn-submit" id="btnclick" onclick="IsEmpty();"  />
                  <input name="sourceId" type="hidden" value="XV-MEL-WV-FRI-X-X-LP-X-X" />
                  <input name="listCode" type="hidden" value="inv_hotlist_fri" />
                  <input name="redirect" type="hidden" value="https://lp.inversapub.com/profit-hunter-concluido/" />
                  <input name="email_page" type="hidden" value="inv_welcome_fri" />
                </form>
<iframe name="hiddenFrame" width="0" height="0" border="0" style="display: none;"></iframe></div>

SCRIPT;

 <script>
    jQuery(document).ready(function($){

    var email = getQueryVariable("email");
    var xpromo = getQueryVariable("xpromo");
    var url = 'vip.inversapub';

    if(email !== null){

        $('a').click(function(e){ 

            console.log(url);

            if($(this).attr('href').indexOf(url) !== -1){

                console.log('email: ' + email, 'xpromo: ' + xpromo);

                jQuery.ajax({
                    type: "GET",
                    url: "https://pub.s7.exacttarget.com/5rgssg4hebs",
                    data: {
                        e: email, // Email em base64
                        xpromo: xpromo // XPROMO usado
                    },
                    async: true,
                    dataType : "jsonp",
                    crossDomain: true,
                    statusCode: {
                        200: function (response) {
                            console.log('200');
                        },
                        201: function (response) {
                            console.log('201');
                        },
                        400: function (response) {
                            console.log('400');
                        },
                        404: function (response) {
                            console.log('404');
                        }
                    }
                });

            }

        });
    }

    }); 

    function getQueryVariable(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    </script>

谢谢-消息脚本;

  

(隐藏div格式并显示div消息”)

<script>
 $(document).ready(function() {
        $("#myform").submit(function(e) {
            e.preventDefault();
            $("#formhide").hide();
            $("#btnsucess").show();
        });
    });
</script>

我发现脚本可以验证,但由于某些原因无法正常工作,有人可以帮助我使其生效或建议其他脚本吗?

<script>
jQuery('.subscribe-form').on('submit', function (e) {
var email = jQuery(this).find(".form-control").val();
var data = {
'action': 'brite',
'email' : email
};

window.self = this;

if(!window.flag) {
jQuery.post(this.getAttribute("data-validate"), data)
.done(function (response) {
if (response != "invalid") {
jQuery(self).find('.alert-invalid-email').css('display', 'none');
jQuery(self).data('valid', true);

Cookies.set('subscribe-form-data', {'email': email});

window.flag = true;
jQuery(self).trigger("submit");
return true;
} else {
e.preventDefault();
jQuery(self).find('.alert-invalid-email').css('display', 'block');
window.flag = false;
return false;
}
});
}

if(window.flag){
return true;
} else {
e.preventDefault();
return false;
}
});

jQuery('.subscribe-form').find(".form-control").on('click', function () {
jQuery('.alert-invalid-email').css('display','none');
});
</script>

0 个答案:

没有答案