I’ve only implemented the submit button locking code (not the form hiding part) from frjo’s suggestion, and that is working great already:
// Unlock the submit button if mouse is moved (desktop)
window.addEventListener('mousemove', function () {
document.getElementById("submitBtn").disabled = false;
});
// Unlock the submit button if touchscreen is dragged (mobile)
window.addEventListener('touchmove', function () {
document.getElementById("submitBtn").disabled = false;
});
// Unlock the submit button if tab or enter is pressed (keyboard)
window.addEventListener('keydown', function (e) {
if ((e.key === "Enter") || (e.key === "Tab")) {
document.getElementById("submitBtn").disabled = false;
// console.log(e.key);
}
});
Some (but very little) spam gets through. What has worked great for the remaining spam, is cycling through the POST values before sending them, and do a simple check for a URL in any fields that shouldn’t naturally contain any (since most spam wants you to click on a URL, which will only show up as a blue link if it contains http:// or https://):
// for spam, check if string contains a URL
function containsUrl (content) {
return (/(https?:?\/\/)/.test(content));
}
That simple check has worked great also. Obviously proceed with caution and only apply to fields that really would not contain URLs naturally. Thanks again frjo!