• Resolved sagescorp

    (@sagescorp)


    Hello sir,
    I want to add custom validation a textarea. Tried different options but no success. Can you help me to solve this issue.

    add_action( 'user_registration_validate_textarea_1666081401','ur_validate_textarea_1666081401',10,4);
    function ur_validate_textarea_1666081401($single_form_field, $data, $filter_hook, $form_id) {    
    	global $wpdb;
        $field_label = isset( $data->label ) ? $data->label : '';
        $value = isset( $data->value ) ? $data->value : '';
    	if( 'textarea_1666081401' === $single_form_field->general_setting->field_name ) {
    		if ( 10 < strlen( $value ) ) {
    		add_filter($filter_hook, function ( $msg ) use ( $field_label ) {
    			return __( $field_label . ' cannot exceed 10 characters.', 'user-registration' );
    			});
    		}
    	}
    }

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Validation’ is closed to new replies.