ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Best practice for mandatory checked checkbox in Safecracker

September 04, 2012 6:45am

Subscribe [1]
  • #1 / Sep 04, 2012 6:45am

    milk_

    9 posts

    Hi everyone.
    What would be the best practice to have a safecracker validation on a mandatory checkbox for a custom Safecracker registration form?

    Basically I need to have a checkbox that MUST be selected in order to register.
    If the user wants to register he has to accept the terms.
    If the checkbox is unchecked I should obtain an inline message stating that the field is mandatory.

    Thank you in advance.

  • #2 / Sep 04, 2012 7:53am

    Rob Allen

    3114 posts

    You can add a rules: paramater to the Safecracker tag to make the field required - see http://ellislab.com/expressionengine/user-guide/modules/safecracker/index.html#rules-my-field-name , eg

    rules:checkbox_field_name=“required”

    There are also options for inline validation and errors on that same page.

  • #3 / Sep 04, 2012 8:37am

    milk_

    9 posts

    Thank you for pointing me in the right direction.

  • #4 / Sep 05, 2012 5:20pm

    Kevin Smith

    4784 posts

    Thanks for the help, Rob!

    milk_, is there anything else you need help with?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases