Javacript for showing Div on click using getElementsByClassName
<p>I am having a div in my page like this,</p>

<pre><code> &lt;div class="errordiv" style="display: none;"&gt;Username is empty&lt;/div&gt;
</code></pre>

<p>i am having an input field and a button like this,</p>

<pre><code>&lt;input type="textbox" id="txt1" /&gt;
&lt;input type="button" value="Submit" id="btn1" onclick="validate();" /&gt;
</code></pre>

<p>I have tried something like this, </p>

<pre><code>function validate() {
    //alert('hi');
    var inptextbox = document.getElementById('txt1');
    //alert('level zero');
    var errorMsg = document.getElementsByClassName('errordiv').item();
    //alert('level ground');
    if (inptextbox.value == '') {
        //alert('hi2');
        errorMsg.style.display = 'block';
    } else {
        errorMsg.style.display = 'none';
    }
}
</code></pre>

<p>The above js code is not working. I am not getting the level ground alert. I dont know what is missing. Please help...</p>

<p>P.S : I don't want Jquery as my page has some restriction to use library files.</p>
