ColdFusion isDefined

前端 未结 4 639
名媛妹妹
名媛妹妹 2021-01-05 19:01

I am trying to check to see if data exist in my form If data does not exist I want to assign it to O. How can I do this.



        
4条回答
  •  自闭症患者
    2021-01-05 19:43

    Technically what you have is fine once you enclose the cfset in tags < and >. Assuming that omission is just a typo, could it be you are trying to use it with a text field?

    Text fields always exist on submission. The value may be an empty string, but the field itself still exists, so IsDefined will always return true. If that is the case, you need to examine the field length or value instead. Then do something if it is empty according to your criteria. For example:

     
     
         do something 
     
    
     ... OR 
    
     
     
         do something 
     
    
     ... OR 
    
      
     
    

提交回复
热议问题