So I am trying to make a javascript function in html that will accept email addresses and then submit them to a web form. How do I do this? this is what I have so far:
<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>
在您的form-action.php火插入查询中,它将在数据库表中提交数据。
用以下行替换if (document.getElementById('email').value.length === 0)
if (document.getElementById('email').value.length == 0)
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.