Auto and Custom Server-side validation for a honey pot field

alan.bagley 04 Jan, 2012
Hi,

I am using CF Version 4.0 RC1.9 and setting up a simple contact form and want to add a "honey pot" field so that if the field is filled in (not blank) then the form will either redirect to an external site or the form will not submit.

I have the form and the code working, emails get sent etc. but the additional custom server side validation is not working, the emails.

Form is as follows:
<h2>Get in touch</h2>
<p>We'll get right back to you...</p>

<input class="form-box" name="name" type="text"  onfocus="if (this.value == 'Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Name';}" value="Name" size="28" /><br />

<input class="form-box" name="tel" type="text"  onfocus="if (this.value == 'Tel') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Tel';}" value="Tel" size="28" /><br />

<input class="form-box" name="email" type="text"  onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}" value="Email" size="28" /><br />

<span style="display: none;" class="form-box">
    <input class="cf_inputbox" maxlength="40" size="28" title="" id="text_7" name="check" type="text" />
</span>
<div>
<input type="image" src="/khan/images/submit.png" name="submit" value="Submit" />
</div>

</div>

I have my events set up like this:Auto and Custom Server-side validation for a honey pot field image 1

What code / or where do I need to put in the custom validation so that if the "honey trap" field has been filled out the form will not get submitted.
I was working around this:

<?php
// No HTML tags allowed
//// plain text
if ( $form->data['check'] == '' )
    return true;
else
{
header( 'Location: http://www.google.com' ) ;
}
?>


Any pointers would be great to get this working

Thanks
Alan
GreyHead 08 Jan, 2012
Hi Alan,

I don't' see an Event Loop action in the Custom Serverside Validation action On Fail event so it doesn't actually 'do' anything. If there is no action the execution just passes to the next action in the On Submit event.

BTW I think Max has added some support for Honeytrap inputs in CFv4 RC3.0 Check the new Security Question input and the Load and Check Security Question actions.

Bob
alan.bagley 13 Jan, 2012
Hi Bob,

thanks I did miss the event loop😶 all sorted

Kind regards
Alan
This topic is locked and no more replies can be posted.