嗨,我希望在验证后通过电子邮件发送表单的详细信息,但我不知道如何在我想要发送详细信息的地方放置警报,这是我的代码示例
if(compName)
{
document.getElementById('country').focus();
compName=true;
if(compContry)
{
document.getElementById('Phone').focus();
compContry=true;
if(compphone)
{
document.getElementById('email').focus();
compphone=true;
if(compemail)
{
//this is where i want to send details of form in email
alert("Your Details Are Sent ");
compemail=true;
}
else
{
document.getElementById('email').focus();
compemail=false;
}
}
else
{
document.getElementById('Phone').focus();
compphone=false;
}
}
else
{
document.getElementById('country').focus();
compContry=false;
}
}
else
{
document.getElementById('username').focus();
compName=false;
}
}
最佳答案
您无法使用 JavaScript 发送电子邮件,您能得到的最接近的结果是 mailto
,它会打开默认电子邮件客户端 - 但不会发送任何内容。
电子邮件应该从服务器发送 - 以正常方式提交表单,并在服务器上构建电子邮件并发送。如何执行此操作取决于您在服务器上运行的内容。
关于javascript - 如何用 JavaScript 打开电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5801152/