I\'m using the below code to try to trim the string in Javascript but am getting the error mentioned in the title:
function trim(str) { return str.replac
In case of a number you can try to convert to string:
var stringValue = str.toString(); return stringValue.replace(/^\s+|\s+$/g,'');