如何创建将提交到Web表单php的电子邮件按钮?

时间:2013-10-18 04:32:41

标签: javascript php html

所以我试图在html中创建一个javascript函数,接受电子邮件地址,然后将它们提交到Web表单。我该怎么做呢?这就是我到目前为止所做的:

<html>
<form name="form" method="post" action="form-action.php">
<label>
Email:
</label>
<input type="email" name="email"
id="email" size="25" />

<input type="button" value="Submit" onclick="SubmitEmail()" />
</form>
<script type="text/javascript">
    function SubmitEmail() {

                if (!ValidateForm()) {

                    return false;

                }


                document.getElementById("form").submit();
function ValidateForm() {
if (document.getElementById('email').value.length === 0) {

alert("Email is Required");

return false;

}

document.getElementById('EmailRslt').value = document.getElementById('email').value;

return true;

}

</script> 
<td>Your Email is:
</td>
<td id="EmailRslt"></td>
</html>

2 个答案:

答案 0 :(得分:0)

在你提交的form-action.php fire insert查询中   数据库表中的数据。

答案 1 :(得分:0)

替换if (document.getElementById('email').value.length === 0)这一行
if (document.getElementById('email').value.length == 0)