How to trim string value :: JavaScript Tutorial Aasim Naseem, July 29, 2010March 18, 2024 hi all.. hope everything is good at your end .. today, there is a smal tip for javascript users … umm infact 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 befor submitting to server side here is the quick way to do this . <script type=”text/javascript” language=”javascript”> function trim(paramString){ return paramString.replace(/^\s*/, “”).replace(/\s*$/, “”); } </script> and thats it … happy development 🙂 Please follow and like us: Aasim NaseemI’m an engineer by profession, a blogger and a photojournalist by hobby. Seasonal writer at LAFZ Media UK. I write on different topics and things around us. Contact me at +971.56.126.8842 or Aasim.Naseem@outlook.com JavaScript Tips & Tutorials How to trim string valuejavascript trimJavaScript TutorialjavascriptsTutorials