How do I handle apostrophes when using apex:inputtext component to set the value of a search?
Some searches indicate string.escapeSingleQuotes(searchString);
or {!JSENCODE(!searchString)}
would resolve but I am confused on appropriate usage.
Example of Component:
<apex:page controller="myClass" showHeader="true">
<apex:inputText id="searchString" value="{!searchString}" onkeypress="return noenter(event);"/>
</apex:page>
Example of Controller:
public class myClass {
Public string searchString{get;set;}
}
Error Received:
EX: Searching O'Doole = unexpected token: 'Doole'
This variable is used to set another variable in myClass:
if(searchType == 'lastNameSearch') {
searchWhere = 'client_Last_Name = \'' + searchString + '\'';
searchLastName = true;
}