我需要检查表单字段是否为空,如果不是,我需要 JS 返回一个值并通过 PHP 提交表单,然后将其发送到另一个页面,在该页面中编写和发送邮件等,我可以做到这一点。
问题是提交验证表格,这是我所拥有的:
<script>
function popup()
{
if (document.getElementById("email").value == "") {
alert("Please enter a email adress");
return false;
}
else
return true; // this is where i have issues the issue, it returns true, but how do i submit the form when it returns true
}
</script>
HTML 表单:
<form action="email_func.php" class="signup_form" data-remote="true" id="signup_form" method="post" >
<input class="txt accent-color colorize_border-color required" id="email" name="email" placeholder="Indtast din E-mail" data-label-text="Email" type="email">
<input class="submit button big btn" id="submit_button" name="submit" value="abc" onclick="popup()">
</form>