{"id":907,"date":"2012-06-13T03:59:15","date_gmt":"2012-06-13T03:59:15","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=907"},"modified":"2012-06-13T03:59:15","modified_gmt":"2012-06-13T03:59:15","slug":"jquery-textarea-empty-how-to-check-if-textarea-is-empty-using-jquery","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-textarea-empty-how-to-check-if-textarea-is-empty-using-jquery\/","title":{"rendered":"Check if Textarea is Empty using jQuery Examples"},"content":{"rendered":"<p>Have you ever wondered <em><strong>how to check if Textarea is Empty using jQuery<\/strong><\/em>? In this article, I am going to share a very easy way that you can use to check if\u00a0Textarea is Empty using jQuery.<!--more--><\/p>\n<h2>How to check if Textarea is Empty using jQuery &#8211; Examples<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=907\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>For this example, I am assuming that we have a Textarea in a form and we need to check if this textarea is empty or not when the &#8220;Check&#8221; button is clicked. The following is the complete source code:<\/p>\n<h3>Example: Use jQuery to check if textarea is empty<\/h3>\n<pre class=\"lang:xhtml decode:true\">&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;jQuery: Check if Textarea is empty&lt;\/title&gt;\n&lt;script type=\"text\/javascript\" src=\"js\/jquery_1.7.1_min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n\n&lt;form name=\"form1\" method=\"post\" action=\"\"&gt;\n&lt;label for=\"comments\"&gt;Comments:&lt;\/label&gt;\n&lt;textarea name=\"comments\" id=\"comments\"&gt;&lt;\/textarea&gt;\n&lt;\/form&gt;\n&lt;button id=\"check\"&gt;Check&lt;\/button&gt;\n\n&lt;script type=\"text\/javascript\"&gt;\n\n$('#check').click(function() {\n\nif ( $('#comments').val() == '' )\n{\nalert('Empty!!!');\n}\nelse\n{\nalert('Contains: ' + $('#comments').val() );\n}\n\n});\n\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>Once you run the above code and click the &#8220;Check&#8221; button, the page will alert &#8220;Empty!!!&#8221;. If you enter something in it and then click the button, it will show the value you entered.<\/p>\n<h5>Simple, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to <em><strong>check if textarea is empty using jQuery<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered how to check if Textarea is Empty using jQuery? In this article, I am going to share a very easy way that you can use to check if\u00a0Textarea is Empty using jQuery.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[42,77,41],"class_list":["post-907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-demos-2","tag-jquery-textarea","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-eD","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=907"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/907\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}