Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我发现了在 html 联系表单中包含一个额外字段的想法,然后使用 CSS 将其隐藏,这样垃圾邮件就会填充它而人类不会。我创建了这个隐藏字段。我的问题是这样的:
如何使该字段必须为空白才能发送表格?我有设置表单,当缺少必填字段时会显示一条消息,所以我猜它与此相反?
你可以通过 JavaScript 来做:
function send(){ if(document.getElementById(yourSendButton).value == "") // go on else //the field is filled
或按 PHP
if($_POST["nameOfYourButton"] == ""){ //input is acceptable } else{ //PROBLEM }
我建议同时实施。