Jeremy F.
Jeremy F.

Reputation: 1878

APEX 3.2 Text validation for nulls AND blanks

I am using APEX 3.2 and I want to make sure that a text field and a text area are not null AND do not begin with a space.

I have a validation in place for NULLs but if a user enters a single space then that field is no longer considered "NULL".

Any ideas?

Upvotes: 2

Views: 1801

Answers (1)

Justin Cave
Justin Cave

Reputation: 231771

If you want to check whether a field is entirely filled with spaces

IF( TRIM( :P123_FIELD_NAME ) IS NULL )
THEN
  RETURN false; -- P123_Field_NAME is all spaces
ELSE
  RETURN true;
END IF;

If you want to check whether a field begins with one or more spaces

IF( LTRIM( :P123_FIELD_NAME ) != :P123_FIELD_NAME )
THEN
  RETURN false; -- P123_FIELD_NAME starts with spaces
ELSE
  RETURN true;
END IF;

Upvotes: 3

Related Questions