Below is the most commonly used trim prototype/function in javascript. Posting for reference. String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,””) } You can place the above code (wrapped in <script></script>) inside <header> section of your web page or you can place…