jQuery: Get Non-empty Text Area Inputs

jQuery: Get Non-empty Text Area Inputs

Simple solutions to get non-empty text area inputs. Let say you have a list or text area like the following:

<textarea name="remark[about_us] id="remark-about_us"></textarea>
<textarea name="remark[about_us2] id="remark-about_us2"></textarea>
<textarea name="remark[about_us3] id="remark-about_us3"></textarea>
<textarea name="remark[about_us4] id="remark-about_us4"></textarea>
<textarea name="remark[about_us5] id="remark-about_us5"></textarea>
var remarks = $('[name^=remark]');
$.each( remarks, function( index, value ){
	var remark = $.trim($('#'+value.id).val());
	if(remark.length != 0) { 
		console.log(value.id + ' - ' + value.value);
	} else {
		console.log(value.id + ' - empty');

Here a sample I have on my current working project.

Get Non-Empty Text Area

Leave a Reply

Your email address will not be published. Required fields are marked *

sixteen + twenty =