Cannot validate on null in text field

I’m validating whether there is data or not in a text field to throw an error message if it is empty on update.

This field cannot initially be a required field.

The text field in db is varchar 800 allow null.

Field setting in sc are on update and on insert null.

After inserting and updating the text field stays null in the db like it should. The problem is if I echo the text field on update I get nothing. Not a null but nothing, blank, zilch.

I echoed other fields of all different types: select, checkbox, date, time, and they all returned null where they were null. Not the text field!

This really throws a wrench in things. Is this default SC text field behavior or an overlooked bug?

Here is the code, pretty straight forward logic


if ({date_field} != null)  && ({text_field} == null)
	{
$error_message = 'You must enter data into text_field if you selected a date in date_field';
sc_error_message($error_message);
		}

The code never executes correctly because every time it looks at {text_field} it doesn’t see a null even though it is!

I have had luck using this:

if ({date_field} && !{text_field})
{
$error_message = ‘You must enter data into text_field if you selected a date in date_field’;
sc_error_message($error_message);
}

That should pick up that there is a value in the first and not the second fields.

I have found that using the === test works OK

e.g.
if ({date_field} != null) && ({text_field} === null)
etc.