我有一个HostGator提供的基本的HTML/JavaScript联系表单。它工作得很好......如果用户没有提交名称或无效的电子邮件地址,就会弹出一个JavaScript警报。这些警报将保留在屏幕上,直到用户单击确定。但是,如果用户正确提交联系表单,最终成功提醒只能持续1/2秒左右。我试图弄清楚如何在指定的时间内最后发送最终电子邮件成功警报,或者直到用户点击确定按钮,然后将它们重定向到指定页面。这里是链接到HostGator信息的联系表格w/JavaScript http://www.hostgator.com/formmail.shtml,这里是我试图改变的代码,以获得提交后的JavaScript消息,而不是在用户甚至有机会阅读之前消失。Javascript提醒窗口 - 如何设置len
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>FormMail Demo</title>
<script type="text/javascript">
function hgsubmit()
{
if (/\S+/.test(document.hgmailer.name.value) == false) alert ("Please provide your name.");
else if (/^\[email protected][a-z0-9_.-]+\.[a-z]{2,6}$/i.test(document.hgmailer.email.value) == false) alert ("A valid email address is required.");
else if (/\S+/.test(document.hgmailer.comment.value) == false) alert ("Your email content is needed.");
else {
document.hgmailer.submit();
alert ('Thank you!\nYour email is sent.');
}
}
</script>
</head>
<body>
<form action="http://www.mydomain.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" value="[email protected]">
<input type="hidden" name="subject" value="FormMail E-Mail">
Whatever you want to say here<br><br>
Visitor Name: <input type="text" name="name" size="30" value=""><br>
Visitor E-Mail: <input type="text" name="email" size="30" value=""><br>
E-Mail Content: <textarea name="comment" cols="50" rows="5"></textarea><br><br>
<input type="button" value="E-Mail Me!" onclick="hgsubmit();">
<input type="hidden" name="redirect" value="http://www.mydomain.com/redirect-path">
</form>
</body>
</html>
尝试把警报()前提交() – anuragsn7 2012-04-08 09:31:15