javascript form validation if element exist
<p>Im making a form validation and im creating a dom dynamically but when I press the submit button to create the error it is calling the element multiple times instead of once. So how can I make it call it once? Im a little lost on this one.</p>

<p><strong>Javascript:</strong></p>

<pre><code>function validateForm(){
var xfields=document.forms["form1"]["amt"].value;
if (xfields==null || xfields==""){
  var errortag = document.createElement('label');
  var realinput = document.getElementById('amt');
  var errortagname = 'error';
  errortag.setAttribute('class',errortagname);
  errortag.innerHTML = 'Amount of loan needed';
  var adddiv = document.getElementById('amtloan').insertBefore(errortag, realinput.nextSibling);
  if(adddiv === true){
      document.getElementById('amtloan').insertBefore(errortag, realinput.nextSibling);
  return false;
      }else{
        xfields.remove('errortag');
    }
}
  return true;
}
</code></pre>

<p><strong>HTML</strong></p>

<pre><code>&lt;div id="st-widget" style=" width: 393px; padding-bottom: 0;"&gt;
&lt;form class="ui-form ui-widget-form" id="short_form" method="get" name="form1" target="_blank" onsubmit="return validateForm()"&gt;
      &lt;input type="hidden" &gt; &lt;input id="scl" name="scl" type="hidden" value=""&gt; 
      &lt;input name="optInQ" type="hidden" value="t"&gt;
      &lt;input name="inplst" type="hidden" value="BSGAEOZ"&gt;

    &lt;div class="grad-date" style="clear:left; #width:138px;"&gt;
       &lt;label for="gradDate"&gt;When will you graduate?&lt;/label&gt;
           &lt;select id="gradDate" name="gradDate" style="width:46px !important;"    tabindex="10" title="Month"&gt;
              &lt;option selected="selected" value=""&gt;Month&lt;/option&gt;
              &lt;option value="January"&gt;January&lt;/option&gt;
              &lt;option value="February"&gt;February&lt;/option&gt;
              &lt;option value="March"&gt;March&lt;/option&gt;
              &lt;option value="April"&gt;April&lt;/option&gt;
              &lt;option value="May"&gt;May&lt;/option&gt;
              &lt;option value="June"&gt;June&lt;/option&gt;
              &lt;option value="July"&gt;July&lt;/option&gt;
              &lt;option value="August"&gt;August&lt;/option&gt;
              &lt;option value="September"&gt;September&lt;/option&gt;
              &lt;option value="October"&gt;October&lt;/option&gt;
              &lt;option value="November"&gt;November&lt;/option&gt;
              &lt;option value="December"&gt;December&lt;/option&gt;
          &lt;/select&gt;
          &lt;select id="grad-month" name="gradDate" style="width:46px !important;" tabindex="15" title="Year"&gt;
              &lt;option selected="selected" value=""&gt;Year&lt;/option&gt;
              &lt;option value="2011"&gt;2011&lt;/option&gt;
              &lt;option value="2012"&gt;2012&lt;/option&gt;
              &lt;option value="2013"&gt;2013&lt;/option&gt;
              &lt;option value="2014"&gt;2014&lt;/option&gt;
              &lt;option value="2015"&gt;2015&lt;/option&gt;
              &lt;option value="2016"&gt;2016&lt;/option&gt;
              &lt;option value="2017"&gt;2017&lt;/option&gt;
          &lt;/select&gt;
    &lt;/div&gt;
    &lt;div id="amtloan" class="amount"&gt;
        &lt;label for="amt"&gt;Amount of loan needed?&lt;/label&gt;
           &lt;input class="amt-input required" id="amt" name="amt" style="width:137px;" tabindex="20" title="Amount of loan needed" type="text" value=""&gt;
    &lt;/div&gt;
    &lt;div class="ui-form-action" style="margin-top:18px;"&gt;
       &lt;button class="ui-btn button" id="" name="go" tabindex="35" title="GO" type="submit" value="Submit"&gt;
      &lt;span class="ui-btn-ctn medium"&gt;Continue &lt;/span&gt;
   &lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;&lt;/div&gt;&lt;/div&gt;
</code></pre>
