I tried adding REQUIRED
attribute using .attr("required","true");
but its not making text area compulsory. Do not want to make all textarea
, compulsory, hence trying to do it dynamically.
$("input"). attr("required", "true");
HTML <textarea> required Attribute The required attribute of the <textarea> element in HTML is used to let visitors know that this textarea field is to be filled before submitting the form. If a visitor clicks on Submit, without filling the textarea set with required attribute, then the form won't submit.
You might not need jQuery. jQuery and its cousins are great, and by all means use them if it makes it easier to develop your application. If you're developing a library on the other hand, please take a moment to consider if you actually need jQuery as a dependency.
$('#myTextarea').prop('required',true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With