Jump to content

<cfif isdefined is not working

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
swapna

swapna

    Newbie

  • Members
  • Pip
  • 1 posts
I am using cold fusion 8 to develop forms. I need to check if user has entered a value of type "text". If not then a message has to Cfoutput. i am using the following code:

<cfif not isdefined("form.question")>
<cfoutput> Enter question
</cfoutput>

</cfif>


The problem is even f nothing is entered in the Question Field, the message Enter question is not being displayed. Its as is the <cfif not isdefined("form.question")> is not at all being recognised.
I also tried <cfif not isdefined("form.question_now")>

Please help.

#2
twalters84

twalters84

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
Hey there,

Try this:

<cfif not isdefined("form.question") OR #form.question# EQ "">
<cfoutput>Enter question</cfoutput>
</cfif>

Your problem is when the form is submitted the question variable is defined, but it is set to an empty string.

Sincerely,
Travis Walters
spammy sig deleted