Form validation

This is my form field

$form['loyalty_code'] = array (
            '#name' => 'loyalty_code',		
            '#id' => 'loyalty_code',
            '#type' => 'textfield',
            '#title' => ('LOYALTY CODE'),
            '#required' => TRUE,
            '#prefix' => '<hr>					
                         <div class="label-wrap loyalty-code">',
            '#suffix' => '</div>',

This is my validation

public function validateForm(array &$form, FormStateInterface $form_state) {	
		$loyalty_code = $form_state->getValue('loyalty_code');		
    	if (strlen(trim($loyalty_code)) !== 12 ){
		echo "ppp";		
        	$form_state->setErrorByName('loyalty_code', $this->t('The loyalty code is the wrong length.'));	
			echo "zzz";				

But it isn’t working

It am getting both the ppp and zzz echos but the form is being submitted and I am not getting any error message?

Any idea why pleas as it look ok to me

Drupal version: