Best way to display javascript text in outputFormatted
514760Mar 31 2008 — edited Mar 31 2008I currently have an outputFormatted field where I display what users have previously typed in. Sometimes users will put in sections of code such as this:
<SCRIPT LANGUAGE="JavaScript">
function CheckForEnter(objInput, evt) {
var keyCode = document.layers ? evt.which : document.all ?
evt.keyCode : evt.keyCode;
if (keyCode != 13)
return true;
else {
// OK have the Enter key. Get the button and click it.
var strBtnName = objInput.LinkedButton;
var objBtn = document.getElementsByName(strBtnName)[0];
objBtn.click();
return false;
}
}
</SCRIPT>
and here is what is getting displayed in my outputFormatted (note the missing script tags):
function CheckForEnter(objInput, evt) {
var keyCode = document.layers ? evt.which : document.all ?
evt.keyCode : evt.keyCode;
if (keyCode != 13)
return true;
else {
// OK have the Enter key. Get the button and click it.
var strBtnName = objInput.LinkedButton;
var objBtn = document.getElementsByName(strBtnName)[0];
objBtn.click();
return false;
}
}
What is the best way to handle this? Should I try to escape the < and > when I check what the user entered?
Thanks in advance,
Chris