+ Start a Discussion

How to eliminate special character ?

Good day,


I need to invoke ajax call when user tick on checkbox, below is the code



<apex:inputCheckbox value="{!myvalue}" rendered="{!hasField}" onclick="{! 'javascript:if(document.getElementById('myField') == null){alert('Message call');} else { handleClicked();} '}}" />

When i put in this and save, it prompt me error on missing '}'  ....i try putting '\' in front of all single quote and it able to save , but it doesn't function when i tick on it 



'javascript:if(document.getElementById(\'myField\') == null){alert(\'Message call\');} else { handleClicked();} '


any clue how i can fix it ? Thanks in advance







Best Answer chosen by Admin (Salesforce Developers) 
Richie DRichie D



Think this'll work:-



<apex:inputCheckbox value="{!myvalue}" rendered="{!hasField}"onclick="javascript&colon;if(document.getElementById('myField') == null){alert('Message call');} else { handleClicked();}"/>