Simple Anti-Spam Request

Permalink
I've been searching this morning, but I can not find a definitive answer.
I am looking to create a required anti-spam field that simply says:
What is 1+1?

I have created the field but now need to validate this field to only accept the number 2.

Attached is an image of where I am up to:

Not sure where to start on this one?

1 Attachment

 
jasteele12 replied on at Permalink Reply
jasteele12
It is quite sad that something as simple as this is not already part of the core.

This has been a problem for clients of mine for years...
JohntheFish replied on at Permalink Reply
JohntheFish
This is effectively a captcha and would be implemented as a captcha package.
jasteele12 replied on at Permalink Reply
jasteele12
Thanks for responding @JohntheFish, but I think it still misses the whole point.

So with 8.5.2 we have ReCAPTCHA added, but even with new Express forms not even client-side required checking happens, and an end-user still can't do something as simple as this.

Not to mention even today on longer forms (not meeting required fields or even on success) requires scrolling back up to see the success/error message(s). The whole form UX bites.

Very unfortunately, concrete5 is about 5 years behind on this one. Oh yeah, this post is from 2015.

Maybe I missed it, but what package are you referring to?
JohntheFish replied on at Permalink Reply
JohntheFish
reCaptca used to be implemented as a package, now its in the core.

For others, see https://www.concrete5.org/marketplace/addons/-/view/?submit_search=1...

Lists Simple Math Captcha https://www.concrete5.org/marketplace/addons/simple-math-captcha...

The main limitation with the core mechanism is that only one captcha can be active at a time, so you cant have 'simple math' and reCaptcha both active on a form.

And yes, I agree that core form UX could be better, especially when trying to design and layout a form. I suppose it all depends on who has time to work on it and what their priorities are.

One good improvement is @mnakalay's Ajax enhancement
https://www.concrete5.org/marketplace/addons/ajax-for-express-forms-...

My Magic Tabs can be used to tabbify a form so it doesn't spread down the page
https://www.concrete5.org/marketplace/addons/magic-tabs1... and works with ajaxed forms
https://demo.c5magic.co.uk/addons/magic-tabs/splitting-form-tabs...
byvictoria replied on at Permalink Reply
byvictoria
Hi,
I am not technical, but someone made me an easy fix for this...
My problem with the core captcha was that the image was always too illegible and I didn't want to give my clients hard time to submit an order form.

So my friend made a new template for the express form block.
We created a view.js file with this content:
$(document).ready(function () {
        $("[id^=captchasubmit]").attr("disabled", true);
//      $("[id^=captchasubmit]").css("border","4px solid red");
    $("[id^=captchatext]").keypress(function (event) {
   //     $("#captchatext").on("change", function (event) {
            if ($(this).val() == "1") {
                $("[id^=captchasubmit]").attr("disabled", false);
         //   $("[id^=captchasubmit]").css("border","4px solid green");
            } else {
                $("[id^=captchasubmit]").attr("disabled", true);
      //      $("[id^=captchasubmit]").css("border","4px solid red");
            }
        });
    });


You are supposed to enter "1" on the box capchta. The problem here was that the submit button wouldn't be activated until you pressed a key. I didn't wan't to put the captcha in the beginning of the form, so what I did was to ask for an answer that involved a two digit number. 10 + 4. You are supposed to enter 14, but any number that starts with 1 will work, which I think is fine for my purposes....

This is the content of my view.php that includes a captcha image previously uploaded into the file manager

<?php
$UID=uniqid();
defined('C5_EXECUTE') or die('Access Denied.');
/** @var \Concrete\Core\Block\View\BlockView $view */
/** @var \Concrete\Core\Express\Form\Renderer|null $renderer */
/** @var string|null $success */
/** @var string $bID */
/** @var \Concrete\Core\Error\ErrorList\ErrorList|null $error */
/** @var \Concrete\Core\Captcha\CaptchaInterface|null $captcha */
/** @var string $displayCaptcha "0" or "1" */
/** @var string $submitLabel */
?>
<div class="ccm-block-express-form">
    <?php if (isset($renderer)) {
    ?>


I also added a view.css, but I guess you don't need that.

I hope it makes sense?