简体   繁体   中英

Javascript contact form doesn't execute/send email

 <script type="text/javascript"> function validateform() { var inputbericht = document.forms["formulier"]["bericht"].value; var inputmail = document.forms["formulier"]["mail"].value; var inputvoornaam = document.forms["formulier"]["Voornaam"].value; if (inputvoornaam == null || inputvoornaam == "") { alert("Naam moet worden ingevuld!"); return false; } if (inputmail == null || inputmail == "") { alert("E-mailadres moet worden ingevuld!"); return false; } if (inputbericht == null || inputbericht == "") { alert("Een bericht moet worden ingevuld!"); return false; } } </script> 
 <form action="mailto:MYEMAIL" method="post" name="formulier" onsubmit=" return validateform()"> <p>Naam: <input type="text" name="Voornaam"></p> <p>E-mailadres: <input type="text" name="mail"></p> <p>Bericht: <br><br><textarea name="bericht" rows="5" cols="110"></textarea></p> <p><input type="submit" name="submit" value="Verzenden"></p> <br> </form> 

I've changed my email with MYEMAIL to censor my email adres. When filling in the form and clicking on submit, I don't receive any email. It seems something isn't executed right, I think I should add something to the submit button, but I'm not quite sure what and why.

AFAIK that approach won't work. You need to send the submitted data to a script of some sort which will then send it using a mail protocol.

If you wan't to use a full JavaScript solution there's always Mandrill . If you're using PHP, and your server supports it, you might use something like the mail() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM