• Resolved eadwig

    (@eadwig)


    Hello

    Although I read Advanced Topics time again, I still can’t work out how a checkbox field can be validated.

    As far as the checkbox is concerned, the code I entered in theme-my-login.php is as follows:

    
    function add_tml_registration_form_fields() {
     tml_add_form_field( 'register', 'agreement', array(
      'type'     => 'checkbox',
      'label'    => __( 'sample text' ),
      'value'    => tml_get_request_value( 'agreement', 'post' ),
      'id'       => 'agreement',
      'priority' => 15,
     ) );
    }
    
    function validate_tml_registration_form_fields( $errors ) {
     if ( ( $_POST['agreement'] == '') ) {
    		$errors->add( 'empty_agreement', '<strong>ERROR</strong>: To register with us, you are required to agree to our Terms and Conditions.' );
     }
    }
    

    Please provide me with suggestions to get the validation working.

    • This topic was modified 6 years, 9 months ago by eadwig.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Cannot validate checkbox type form field’ is closed to new replies.