Here is the simple function that gets called when a button is clicked:
// Contact form
function sendEmail(){
var name = document.getElementById("nameField").value;
var email = document.getElementById("emailField").value;
var subject = document.getElementById("subjectField").value;
var message = document.getElementById("messageField").value;
if(name != "" && email != "" && subject != "" && message != ""){
var url = 'mailto:email@emailprovider.com?subject=' + name + ' (' + email + ')' + ' ' + subject + '&body=' + message;
window.location.href = url;
} else {
console.log("SOMETHING WAS EMPTY");
}
};
But then it keeps redirecting me to http://127.0.0.1:5500/# instead of http://127.0.0.1:5500/ How do I prevent this?
I figured out what the issue was. I had action=“#” in the form html. I will mark this as answered.