Object required in validation
<p>I am trying to validate code in javascript. Here is my code:</p>

<pre><code>if(document.getElementById("name").value == ""){
    alert("Name is a required field");
    document.getElementById("name").focus();
    return false;
}
</code></pre>

<p><code>name</code> is id in my html page:</p>

<pre><code>&lt;div class="app-form-box"&gt;
  {% if review %}
    {% if not review.name %}
      &lt;input type="text" alt="" onkeyup="return validateField(name)" tabindex="2" name="name" id="name" class="disabled inputtxtlarge" onfocus="highlightInput(this.id)" onblur="return (!validateField(name) || unhighlightInput(this.id))" maxlength="50" value="{{name|moonescape}}" disabled="disabled"/&gt;&lt;span&gt; &lt;/span&gt;
    {% else %}
      &lt;input type="text" alt="" onkeyup="return validateField(name)" tabindex="2" name="name" id="name" class="inputtxtlarge" onfocus="highlightInput(this.id)" onblur="return (!validateField(name) || unhighlightInput(this.id))" maxlength="50" value="{{name|moonescape}}"/&gt;&lt;span&gt; &lt;/span&gt;
    {% endif %}
  {% else %}
    &lt;input type="text" alt="" onkeyup="return validateField(name)" tabindex="2" name="name" id="faname" class="inputtxtlarge" onfocus="highlightInput(this.id)" onblur="return (!validateField(name) || unhighlightInput(this.id))" maxlength="50" value="{{name|moonescape}}"/&gt;&lt;span&gt; &lt;/span&gt;
  {% endif %}
  &lt;div class="servererror"&gt;
    {% if form_errors.name %}
      * {{ form_errors.name|join:"| " }}&lt;br/&gt;
    {% endif %}
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>But I am getting <code>OBJECT REQUIRED</code>. Please suggest how to put check in js file for this.  Thanks </p>
