Test works when JavaScript code is internal but not external

I’m checking the content entered in a multiline textarea field using JavaScript. Only certain characters are allowed and if any part of 4 bracket pairs are found, the other part of the pair must be present.

To test the 2nd part of this last statement, I remove one of the bracket parts. I did it with a delete and hi-lite and space leaving a blank space. The change triggers the field check when focus is lost.

When the JavaScript code is internal to the module producing the textarea, the allowed characters test passes and the paired brackets requirements fails. This is correct.

But when I move the JavaScript code to my external JS module, the 1st test fails on the space where I deleted the bracket part. All other blank spaces pass this test until this particular blank space is encountered. It looked like a blank space when I output it or do a charAt. The charCodeAt command gave a 10 or what the unicode table calls a control.

Some of the brackets that may be in this textarea are special characters in JavaScript. Do I have to escape special characters to JavaScript before I load the textarea???

Any help will be appreciated.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.