• Resolved dschmidtke

    (@dschmidtke)


    A checkbox with required attribute as well as the GDPR form element do not validate when checked.

    Steps to reproduce in Formello 2.2.2:

    • Create a new contact form
    • Add GDPR to the contact form
    • Publish it
    • Add the contact form to a new page an try it out.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author tropicalista

    (@tropicalista)

    Can you check if latest update solve this problem?

    Thread Starter dschmidtke

    (@dschmidtke)

    No, it didn’t solve the problem. Here is the markup of the gdpr block used:

    <!-- wp:formello/input {"advanced":false} -->
    <div class="formello formello-checkbox"><label class="" for="field_99ef3d"><span>Ich stimme zu</span><span class="required">*</span></label><input name="checkbox" id="field_99ef3d" type="checkbox" required class=""/></div>
    <!-- /wp:formello/input -->

    And here ist the markup for the enclosing form block:

    <!-- wp:formello/form {"successMessage":"Vielen Dank! Ihre Bestellung wurde gesendet.","errorMessage":"Entschuldigung. Ihre Eingaben sind noch nicht komplett.","lock":{"move":false,"remove":false},"className":"as-row","style":{"spacing":{"padding":{"top":"0","right":"0","bottom":"0","left":"0"}}}} -->
    <form class="wp-block-formello-form as-row" style="padding-top:0;padding-right:0;padding-bottom:0;padding-left:0" method="post" data-id="151" data-hide="true" data-validate="true" novalidate>
    Thread Starter dschmidtke

    (@dschmidtke)

    Moreover after removing the checkbox block, the form does not submit anymore in Formello 2.3.1, outputting

    SyntaxError: Unexpected token '<', "
    Es gab "... is not valid JSON
    Plugin Author tropicalista

    (@tropicalista)

    Can you share a live link?

    Thread Starter dschmidtke

    (@dschmidtke)

    No, I cannot share a link, since the website is in production and I have to roll back immediately.

    However, I noticed that you provided another update (2.3.2). I performed the update again, had the same problem with a checked checkbox not validating, but the json error after removing the checkbox block is gone.

    So I am on 2.3.2 now without a checkbox.

    Plugin Author tropicalista

    (@tropicalista)

    Can you try to set a value for checkbox?

    Thread Starter dschmidtke

    (@dschmidtke)

    Yes, that’s it – the missing value. With JavaScript validation enabled, the form does not validate without a value for the checkbox. As soon as I set “on” as a value it worked.

    However, with JavaScipt validation disabled and HTML5 validation only, the form validates even without a value. And that’s how it’s supposed to work since the HTML spec says that if a checkbox name is submitted with empty value the default value should be “on”.

    So I suggest that you rework the JS validation in Formello and make empty checkboxes validate with “on” as default value.

    Thanks for your support!

    Plugin Author tropicalista

    (@tropicalista)

    I have made some changes to 2.3.3 that perform exactly what you are saying. So this is solved.

    The only differences is that I set “yes” as default value instead on “on” if value is missing.

    I’d probably add a setting to let user choose what is default. What are you thoughts?

    Plugin Author tropicalista

    (@tropicalista)

    This is solved. Let me know if you nedd further assistance. Thanks

    Thread Starter dschmidtke

    (@dschmidtke)

    Sorry for the late reply. I thought about setting a default value or not, and came to the conclusion, that it might be the safest not to set any default – neither “yes” nor “on” – but perform the JS validation in a way where a checkbox, that is checked but has no value, is validating – like it does with HTML5 validation. That way, you are following the standard, and at the same time, your don’t have to make up a value or ask the Formello user to set one, because a value is not necessary.

    For reference:

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value

    https://www.w3.org/TR/2011/WD-html5-20110405/common-input-element-attributes.html#dom-input-value-default-on

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘checkbox not validating’ is closed to new replies.