function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MMA_FORCEMMA_FORCE 

Null Value for inputText box????

Hi:

   I have an inputText Field in VF:

 

<td><apex:inputText value="{!teachername}"/></td>

 Then in my Apex Code I have:

 

if(teachername!=null){
qryString = qryString + 'where ' + teacher + '=' + '\''+ teachername+'\'';
}

 


 

 

Now the issue is if I do not place anything in that textbox and click on another filter and then click go button...

It gives me an error on my where statement bring up the teacher where statement...

 

It is null, I left it blan/empty/nothing in there...

 Should I place something else instead of a null???

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
RCJesseRCJesse

You can try: if(teachername!='')

 

in my apex code a lot of my if statements include both because i'm never exactly sure when a field is null or not. So mine look like  if(* !=null && * != '')

All Answers

RCJesseRCJesse

You can try: if(teachername!='')

 

in my apex code a lot of my if statements include both because i'm never exactly sure when a field is null or not. So mine look like  if(* !=null && * != '')

This was selected as the best answer
sunil316sunil316

yes check both the condition,

 

if( teachername != null && teachername != '')

MMA_FORCEMMA_FORCE
Thank you both for your help on this awesome