Set a text area to be a required part of form submission:
document.getElementById("myTextarea").required = true;
Click the button to set the required property for the area field.
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> Text area:<br> <textarea id="myTextarea" name="adr"> </textarea><br> <input type="submit"> </form>// w w w .java 2 s. c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myTextarea").required = true; document.getElementById("demo").innerHTML = "The required property was set."; } </script> </body> </html>