Thursday, October 28, 2021

javascript error and resolution

There was a page which had our google app script embedded, but on which the app only showed a spinner instead of loading up on Firefox. Checking the error on the browser console, found
Uncaught SyntaxError: invalid range in character class common.js:10:54

Finally found that this was due to a hyphen not being escaped in the common.js file - the hyphen should be escaped, or else it becomes a range from the previous char (.) to the next char (+), which gives an "Invalid range" error, preventing the loading of the entire js file, leading to the function w3_open() not being found.

           if (!element.value.match(/^[0-9a-zA-Z @,.-+]+$/)) {
was to be replaced by 
            if (!element.value.match(/^[0-9a-zA-Z @,.\-+]+$/)) {
   

No comments:

Post a Comment