0
我不确定我想要做什么可能没有PHP或一些其他脚本语言,所以我会很感激的一些建议。Javascript表单提交
我们有一个只能提供静态HTML的web服务器,所以我们有点受限。我们希望将使用JavaScript的表单上的电子邮件注册数据从本网站上的另一个域的dataHandler.php
脚本发送到将其保存到数据库的dataHandler.php
脚本。当客户点击提交时,我不希望页面导航到dataHandler.php
,虽然在我希望它以某种方式刷新的其他域(我不知道如何),并感谢加入我们的电子邮件列表。下面是我想到的代码示例。
任何关于如何实现它的建议都会感激不尽,或者任何意见说停止浪费你的时间也是有帮助的。
<script type="text/javascript">
<!--
function validate() {
if (document.emailForm.email.value.length==0) {
alert("You forgot to enter your email address");
return false;
}
if (document.emailForm.email.value.length>0) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.emailForm.email.value;
if(reg.test(address) == false) {
alert('Invalid email address');
return false;
}
}
document.emailForm.submit()
return true;
}
//-->
</script>
<form id="emailForm" name="emailForm" action="http://www.otherdomain.com/dataHandler.php" method="post">
<input size="30" id="email" name="email" maxlength="200" />
<input onclick="validate();" type="button" value="Submit" />
</form>
令人惊叹的感谢! – 2012-03-08 23:05:23