Validating a number field against the start of an address field

Hi there,
I have created, for me, quite a complicated form for a loan company. I have a number of validations in my functions.php file but I have one that I am struggling with.

I have a field (18) that is a text field and an address field (15). I want to compare field 18 with the first 2 characters of the first line of field 15 (15.1).

I am trying something like this but cannot seem to get it to work:

add_filter( 'gform_field_validation_1_18', function ( $result, $value, $form, $field ) {
    $address1 = rgar( $entry, '15.1'  );
	$house_number = substr( $address1, 0, 2);
    if ( $result['is_valid'] && $value == $house_number ) {
        $result['is_valid'] = false;
        $result['message']  = 'I think you may have entered your house number in this box. Please enter how long you have lived at this address. If the number is correct please add the word YEARS and the resubmit the form';
    }
	    return $result;
}, 10, 4 );

I would appreciate some assistance if possible.

Many thanks,

Ian

Hi Ian. I recommend adding some logging statements to be sure your code is executed, and that the variables contain what you think they should, when you are trying to use them.

https://docs.gravityforms.com/custom-logging-statements/

For the logging to be useful, you will need to have Gravity Forms logging enabled. https://docs.gravityforms.com/logging-and-debugging/

If you need help after that, please send a link to the Gravity Forms Core log (if that is where you are logging) and also post your updated code, so we know what to check in the log.) Thank you.