How to trim string value :: JavaScript Tutorial AasimNaseem, July 29, 2010April 30, 2025 Hi all.. Hope everything is good at your end. Today, there is a small tip for JavaScript users… Umm, in fact, not a tip but a utility function to trim string values… I was working on a project I had a need to trim user input before submitting to server side Here is the quick way to do this . [code language=”javascript”] <script type="text/javascript" language="javascript"> function trim(paramString){ return paramString.replace(/^\s*/, "").replace(/\s*$/, ""); } </script> [/code] And that’s it… happy development 🙂 JavaScript How to trim string valuejavascript trimJavaScript TutorialjavascriptsTutorials