Is there a difference between the two statements?

{!NOT(ISNULL(variable))} and {!variable != null}

What is the appropriate way to check if something is null?

EDIT: What if it's a SF checkbox? Does != null validate if its unchecked or does this not apply here?

2 Answers 2


You can do either way but I prefer {!variable != null}.

One thing that might often be a better idea though is to do the checks in the controller so that less of the logic is in the VF page.

EDIT: SObject booleans will always be true/false. It won't be null.

  • Thanks! I added an edit - as it doesn't seem to apply to checkboxes. Could you address? :) Sep 12, 2014 at 16:00
  • @JacobRaccuia html checkboxes or Visualforce checkboxes?
    – dphil
    Sep 12, 2014 at 18:20
  • checkboxes from a salesforce object - is the box checked? Sep 12, 2014 at 18:28
  • Checkboxes on a Salesforce object can never be null. They have two values, true or false.
    – greenstork
    Sep 12, 2014 at 18:30
  • 1
    However, all apex variables, even booleans can have a null value. It really depends then on whether or not your are binding to an sObject or your own boolean property on your controller.
    – greenstork
    Sep 12, 2014 at 18:33

Either syntax works, both are exactly the same.

  • 1
    True, it's really just a matter of whether you're more used to Excel-style formula syntax or programmer-ish syntax. However, ISNULL() is deprecated - use ISBLANK() instead. Sep 14, 2014 at 3:57
  • If you're checking in the controller you may also use the String method isNotBlank(). However, in VF I don't believe there is an ISNOTBLANK() function, just ISBLANK(). Sep 14, 2014 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.