Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#511 2026-01-01 16:35:07
Re: com_connect - form and contact mailer
jayrope wrote #342062:
Thank you, Jakob. I am not versed with patterns, or RegEx for that matter…
Most of the above is very simple. IIRC a regular term on a blank line also works, so it doesn’t need to be a regex expression. If you wrap the expression with two equal characters, e.g. /…/ then the expression will be processed. The rules above are:
[abc] = one of the contained letters, e.g either a, b, or c
(one|two|three) = one of the contained terms, e.g. either "one", "two", or "three"
\s = One or more spaces, tabs, etc.
? = with or without the preceding item, e.g. \s? = zero or more spaces
(something)? = with or without the preceding group
…and there are many more. regex101.com is a useful site and has a quick reference panel with more options.
TXP Builders – finely-crafted code, design and txp
Offline
#512 2026-01-21 11:57:22
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,331
Re: com_connect - form and contact mailer
jakob wrote #342061:
And there’s another even more effective method which swaps out the form action after a time delay, causing automated bots which fill out forms quickly to land in nirvana while allowing regular (slower) people to submit the form.
Use the
delayattribute to specify the number of seconds before it switches the form action and theactionattribute to specify an alternative (e.g. throwaway) action target, followed by the real one. If it’s the same page as the form, just end the attribute with a comma. Both go in the initialtxp:com_connecttag, for example:
delay="5-15" action="https://binit.domain.com/,"...I found that to be most effective so far.
I also asked Claude AI for a good anti-spam solution and he suggested a so-called “honeypot” solution. Sorry if this solution is already integrated into the plugin.
Here’s a honeypot-only solution:
<script>
// Wait 3 seconds before enabling the submit button
setTimeout(function() {
var submitBtn = document.getElementById('submit-btn');
var hpField = document.getElementById('honeypot');
// Enable button only if honeypot is empty
if (submitBtn && hpField && hpField.value === "") {
submitBtn.disabled = false;
submitBtn.style.opacity = "1";
}
}, 3000);
// Additional check: if bot fills the honeypot, lock the button immediately
function checkBot(val) {
var btn = document.getElementById('submit-btn');
if (val !== "") {
btn.disabled = true;
btn.style.opacity = "0.5";
}
}
</script>
<style>
#submit-btn {cursor: pointer;}
#submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.v-hidden { position: absolute; left: -9999px; top: -9999px; visibility: hidden; }
</style>
<txp:com_connect
---
<div class="v-hidden">
<input type="text" name="website" id="honeypot" onchange="checkBot(this.value)" autocomplete="off" tabindex="-1">
</div>
<txp:com_connect_submit label="Send" id="submit-btn" disabled="disabled" />
</txp:com_connect>
This solution uses only a honeypot field (hidden from real users but visible to bots) plus a 3-second delay before enabling the submit button. No reCAPTCHA included.
Last edited by Gallex (2026-01-21 12:02:06)
Offline
#513 2026-01-23 00:44:05
Re: com_connect - form and contact mailer
Gallex wrote #342326:
This solution uses only a honeypot field (hidden from real users but visible to bots) plus a 3-second delay before enabling the submit button. No reCAPTCHA included.
That is basically the same honeypot solution as is build in the plugin with the delay attribute and some invisible (hidden) field.
The possible advantage of yours is that it would work with some strict CSP that requires nonces and limits inline script blocks, which is where the latest versions of com_connect fail (issue).
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
#514 2026-01-23 01:06:08
Re: com_connect - form and contact mailer
Ack, thanks for the nudge on that CSP issue. I’ll see if it can be solved.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline