This SCRIPT copy the parameter "email=" from URL and paste on a input value. But when that's no parameter on the URL, the scripts copys the entire URL, how can I set to don't copy if doesn't have the "email" parameter ?
Also, is there a way to hide only the "email" parameter on URL, to not show the user email on the URL?
Example: www.mydomain.com/?xpromo=test&email=anselmo@teste.com&date=20190212 I want to hide the "anselmo@teste.com" from the URL but still COPY the email on the input value.
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var url=window.location.href;
var email=url.split("email=").pop(-1);
document.getElementById('email-assinante').value=email;
});
</script>
<form action="https://ws.inversapub.com/subscribe" data-validate="https://lp.inversapub.com/wp/wp-admin/admin-ajax.php" method="POST">
<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 melhor e-mail" class="form-control input-box" value="" id="email-assinante" >
<input type="text" class="form-control input-box" name="celular" placeholder="Deixe aqui seu número de celular com DDD" class="telephone" required="" >
<input type="submit" value="COMEÇAR A RECEBER" class="btn btn-email">
<input name="sourceId" type="hidden" value="XPROMO" />
<input name="listCode" type="hidden" value="HOTLIST" />
<input name="redirect" type="hidden" value="THANK YOU PAGE" />
<input name="email_page" type="hidden" value />
</form>