{"id":240,"date":"2011-06-24T07:02:09","date_gmt":"2011-06-24T12:02:09","guid":{"rendered":"http:\/\/www.g31zone.com\/?p=240"},"modified":"2011-07-22T12:57:27","modified_gmt":"2011-07-22T17:57:27","slug":"240","status":"publish","type":"post","link":"https:\/\/www.g31zone.com\/?p=240","title":{"rendered":"Javascript &#8211; limit the number of characters in a textarea"},"content":{"rendered":"<p>Javascript &#8211; limit the number of characters in a textarea:<\/p>\n<p><code><br \/>\n&lt;script language=\"javascript\" type=\"text\/javascript\"&gt;<br \/>\nfunction limitText(fieldLimit, countLimit, limitNum) {<br \/>\n\tif (fieldLimit.value.length &gt; limitNum) {<br \/>\n\t\tfieldLimit.value = fieldLimit.value.substring(0, limitNum);<br \/>\n\t} else {<br \/>\n\t\tcountLimit.value = limitNum - fieldLimit.value.length;<br \/>\n\t}<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;form name=\"form_name\"&gt;<br \/>\n&lt;textarea name=\"sometext\" onKeyDown=\"limitText(this.form.sometext,this.form.counter,100);\"<br \/>\nonKeyUp=\"limitText(this.form.sometext,this.form.counter,100);\"&gt;<br \/>\n&lt;\/textarea&gt;&lt;br \/&gt;<br \/>\n(Maximum characters: 100)&lt;br \/&gt;<br \/>\nYou have &lt;input readonly type=\"text\" name=\"counter\" size=\"3\" value=\"100\"&gt; characters left.<br \/>\n&lt;\/form&gt;<br \/>\n<\/code><br \/>\n<a href=\"http:\/\/www.mediacollege.com\/internet\/javascript\/form\/limit-characters.html\" target=\"_blank\" rel=\"nofollow\">Read original article<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Javascript &#8211; limit the number of characters in a textarea: &lt;script language=&#8221;javascript&#8221; type=&#8221;text\/javascript&#8221;&gt; function limitText(fieldLimit, countLimit, limitNum) { if (fieldLimit.value.length &gt; limitNum) { fieldLimit.value =&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[178,81],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-javascript-limit-textarea-characters"],"_links":{"self":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=240"}],"version-history":[{"count":5,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":261,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions\/261"}],"wp:attachment":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}