Validate::validate_is_checked( object $field )

Description #

Author – Jay Iyer (06/26/2019) Validate ‘is_checked’ field.

Description – Add the ‘is_checked’ validate method to require the Checkbox field to be checked on form submit.

Parameters #

  • $field
    object (Required) Instance of @see AP_Field object.

Source #

File: lib/class-validate.php

    public static function validate_is_checked( $field ) {
        if ( ! empty( $field ) ) {
            $value = $field->value();
            if (! $value) {
                $field->add_error(
                    'is-checked', sprintf(
                        // Translators: placeholder contain field label.
                        __( 'You are required to check %s field', 'anspress-question-answer' ),
                        $field->get( 'label' )
                    )
                );
            }

        }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment