I'm trying to redirect to a new page on button click using JS function.
The URL should contain email address parameter.
<form>
<input type="email" id="mail" placeholder="YOUR EMAIL ADDRESS" required/>
<input type="submit" value="SEND US THE LIST" onclick="redirect();"/>
<script>
function redirect(){
var email = document.getElementById("mail").value;
window.location.replace("https://rinateithan.com/thank-you?sender="+email);
}
</script>
I have tested my code, once I use normal string with "@" and "." symbols the code works fine. But once I use email address in the URL parameters the redirect fails.
Console.log("https://rinateithan.com/thank-you?sender="+email); // Returns https://rinateithan.com/thank-you?sender=test@gmail.com for example
How can I transfer email address through URL parameters using JavaScript redirection?