Error can't show when click form input
<p>I have a javascript:</p>

<pre><code>&lt;script&gt;
function updatecode() {
    var widthError = "&lt;span style='color:#ff0000'&gt;Error&lt;/span&gt;";
    var width = document.getElementById('width').value;
    if(width &lt; 300) {
        document.getElementById('error_width').innerHTML = widthError;
    }else {
        document.getElementById('error_width').style.visibility = "hidden";
    }
}
&lt;/script&gt;
&lt;input type="text" name="width" id="width" value="auto" onchange="updatecode()" /&gt;
&lt;span id="error_width"&gt;&lt;/span&gt;
</code></pre>

<p>When I enter width = 400, it is ok. And when I enter width = 200, it does not show the error message. How can I fix that?</p>
