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

On Click Javascript and carriage return error.



I have a button with on click javascript attached to it. I am using this to make sure a custom comment field is filled out before sending to my custom apex page. The problem is if the user hits the enter key in the comments then I get an on click javascript error stating there is a unterminated string. Anyone else have this problem? Any ideas on how to get around this?


Here is the code:


var comments;


if(comments==null || comments=="")
alert("Please enter comments into Convert To Lead Comments section!");
window.location= "/apex/ConvertCaseToLeadButton?id={!Case.Id}";