ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How do I create an If:elesif that checks if a field is empty or not?

February 23, 2011 2:04pm

Subscribe [2]
  • #1 / Feb 23, 2011 2:04pm

    dodgson

    120 posts

    Hi There, I have create a page that displays a series of fields. I came across an issue today where a data field was left empty. I would like the page to look to see if the field is empty and if it is, it will give a message. I looked in the user guide, but the if conditionals are all checking against some pre-defined parameter. How do you search for “empty”, then give a message?

    Thanks in advance.

  • #2 / Feb 23, 2011 2:29pm

    Mark Bowen

    12637 posts

    Hiya,

    This should give you what you need :

    {if name_of_custom_field_here != ""}
    {name_of_custom_field_here}
    {if:else}
    Message to show if field has no content
    {/if}

    Do be aware though that if someone places even a space into the field then the message would never show because to all intents and purposes it would have something in it.

    Hope that helps a bit though.

    Best wishes,

    Mark

  • #3 / Feb 23, 2011 2:38pm

    dodgson

    120 posts

    Thanks Mark, That worked perfectly.

  • #4 / Feb 23, 2011 3:38pm

    Mark Bowen

    12637 posts

    No problem at all.

    Glad that worked for you.

    Hope everything else goes well.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases