{"id":1077,"date":"2010-07-29T14:48:21","date_gmt":"2010-07-29T08:48:21","guid":{"rendered":"http:\/\/aasims.wordpress.com\/?p=1077"},"modified":"2025-04-30T12:20:54","modified_gmt":"2025-04-30T12:20:54","slug":"how-to-trim-string-value-javascript-tutorial","status":"publish","type":"post","link":"https:\/\/aasimnaseem.com\/blog\/how-to-trim-string-value-javascript-tutorial\/","title":{"rendered":"How to trim string value :: JavaScript Tutorial"},"content":{"rendered":"<div id=\"_mcePaste\">\n<div id=\"_mcePaste\">Hi all..<\/div>\n<div id=\"_mcePaste\">Hope everything is good at your end.<\/div>\n<div id=\"_mcePaste\"><\/div>\n<div id=\"_mcePaste\">Today, there is a small tip for JavaScript users&#8230;<\/div>\n<div id=\"_mcePaste\">Umm, in fact, not a tip but a utility function to trim string values&#8230;<\/div>\n<div id=\"_mcePaste\">I was working on a project I had a need to trim user input before submitting to server side<\/div>\n<div id=\"_mcePaste\"><\/div>\n<div id=\"_mcePaste\">Here is the quick way to do this .<\/div>\n<div>\n<p>[code language=&#8221;javascript&#8221;]<br \/>\n&lt;script type=&quot;text\/javascript&quot; language=&quot;javascript&quot;&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0function trim(paramString){<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return paramString.replace(\/^\\s*\/, &quot;&quot;).replace(\/\\s*$\/, &quot;&quot;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0}<br \/>\n&lt;\/script&gt;<br \/>\n[\/code]<\/p>\n<\/div>\n<div id=\"_mcePaste\">And that&#8217;s it&#8230;<\/div>\n<div id=\"_mcePaste\"><\/div>\n<div id=\"_mcePaste\">happy development \ud83d\ude42<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/s07.flagcounter.com\/count\/9EI\/bg=FFFFFF\/txt=000000\/border=FFFFFF\/columns=6\/maxflags=200\/viewers=0\/labels=1\/pageviews=1\/\" alt=\"free counters\" border=\"0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all.. Hope everything is good at your end. Today, there is a small tip for JavaScript users&#8230; Umm, in fact, not a tip but a utility function to trim string values&#8230; I was working on a project I had a need to trim user input before submitting to server&#8230;<\/p>\n","protected":false},"author":1,"featured_media":5234,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[513,590,591,592,1025],"class_list":["post-1077","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-how-to-trim-string-value","tag-javascript-trim","tag-javascript-tutorial","tag-javascripts","tag-tutorials"],"_links":{"self":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/comments?post=1077"}],"version-history":[{"count":7,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1077\/revisions"}],"predecessor-version":[{"id":5238,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1077\/revisions\/5238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media\/5234"}],"wp:attachment":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media?parent=1077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/categories?post=1077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/tags?post=1077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}