No idea about the error you are getting, but one suggestion regarding the function StripSpacesFromEnds(s)Instead of using this finction to remove blank spaces/ trim the string, Try this str = str.replace(/^\s*|\s*$/g,''). This is similar to the trim function in vb.....