HTML “textarea” Required Attribute Not Working | How to Fix?

To make an HTML form “textarea” to have a required attribute, all you need to do is to add required or required="required"

But sometimes when you add the required attribute to force the user to input data, it does not work. Here’s how to fix it.

Make sure that the <textarea></textarea> does not have space in between because if it does have then you have already input some character or text.

<!-- Do this -->
<textarea></textarea>

<!-- Dont do this!!!!!!  -->
<textarea> </textarea>

Do not forget to add the required attribute.

<!-- Do this -->
<textarea required></textarea>

<!-- or -->

<!-- This -->
<textarea required="required" ></textarea>

Another reason why you need to make sure that the textarea tag are closed and no space is because if you add a placeholder attribute it wont work.

Voilà 🎉 that’s all.