Knowledge Walls
John Peter
Pune, Maharashtra, India
How to validate textarea using Javascript and HTML with Example
39617 Views
Hints 
In this Example explained about textarea component validation using Javascript.

getElementById() method using to get the Element. with selected element getting and setting the data using value attribute of Element Object in Javascript. focus() method of Element Object in Javascript used to set current cursor control to the Component.
TextareaValidationExample
<html>
    <head>
        <script type="text/javascript">
            function validate(){
               if (document.getElementById("txtarea_consolidation").value == ""){
                   alert("Enter the permanent address");
                   document.getElementById("txtarea_consolidation").focus();
               }
               else {
                   alert(document.getElementById("txtarea_consolidation").value);
               }
            }
        </script>
    </head>
    <body>
        <h2>Permanent Address</h2>
        <textarea id="txtarea_consolidation"></textarea><br />
        <button onclick="javascript:validate();" style="margin: 5px 0px;">Validate</button>
    </body>
</html>
Output 
Best Lessons of "Good Javascript Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details