+ Start a Discussion
SalesRedSalesRed 

Unknown Property String.length

Hello,

 

I am trying to check the length of a string in a visualforce page but I cannot save the page due to the following error

"Unknown Property. 'String.length'

 

My code is as follows

 

rendered="{!if(selectedItem.length==0)}"

 

I'm sure I must be doing something silly here but I would have thought the length function could have been used within a visualforce apex:outputPanel render check.  Do you notice any typo's above. Missed brackets etc or are string functions just not allowed within a visualforce page?

 

Thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

I believe you can use Len(string) in formula expressions.... i.e.

 

rendered="{!if(len(selectedItem)==0)}"

All Answers

aballardaballard

I believe you can use Len(string) in formula expressions.... i.e.

 

rendered="{!if(len(selectedItem)==0)}"

This was selected as the best answer
SRKSRK

U can try this in javascript

var y = "{!selectedItem}";

var x = y.length;

 

or

var x = " "{!selectedItem}".length;