title: jQuery .val() not getting value from one input, fine on the rest
body: <p>I need to validate  a number of fields in my ASP MVC3 view and am trying to use jQuery to do so. The jQuery <code>.val()</code> method pulls the <code>accountNumber</code>, <code>refNumber</code>, and <code>ownerMaster</code> from the input fields just fine, however the <code>agentId</code> field always has a value of <code>""</code> regardless of anything.</p>
  
  <p>I've looked over and over for a typo in my code and haven't found it. Hoping another set of eyes does the trick. </p>
  
  <p>FYI - if I change the <code>.val()</code> on <code>$('#AgentId').val()</code> below to <code>.hide()</code> the hide method works and the field disappears, which means I have the selector typed correctly. </p>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>function ValidateFields(transactionType) {
      var msg = "";
      var refNumber = $('#RefNumber').val();
      var ownerMaster = $('#OwnerMasterAgentId').val();
      var accountNumber = $('#AccountNumber').val();
      var agentId = $('#AgentId').val(); //When the agentId variable an selector + val() are
                                         //evaluated here both have a value of ""
  </code></pre>
  
  <p><strong>ASP MVC Razor</strong></p>
  
  <pre><code>                &lt;div class="M-editor-label"&gt;
                      @Html.LabelFor(model =&gt; model.RefNumber)
                      &lt;span class="alwaysReq"&gt; @Html.Raw("*")&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class="M-editor-field"&gt;
                      @Html.TextBoxFor(model =&gt; model.RefNumber, new { maxlength = 9, @class = "staticData" })
                  &lt;/div&gt;
                  &lt;div class="M-editor-label"&gt;
                      @Html.LabelFor(model =&gt; model.OwnerMasterAgentId)
                      &lt;span class="req"&gt;@Html.Raw("*")&lt;/span&gt; 
                  &lt;/div&gt;
                  &lt;div class="M-editor-field"&gt;
                      @Html.TextBoxFor(model =&gt; model.OwnerMasterAgentId, new { maxlength = 8, @class="staticData" })
                  &lt;/div&gt;
                      &lt;div class="M-editor-label"&gt;
                          @Html.LabelFor(model =&gt; model.AccountNumber)
                          &lt;span class="req"&gt;@Html.Raw("*")&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div class="M-editor-field"&gt;
                          @Html.TextBoxFor(model =&gt; model.AccountNumber, new { maxlength = 17 })
                      &lt;/div&gt;
                      &lt;div class="M-editor-label"&gt;
                          @Html.LabelFor(model =&gt; model.AgentId)
                          &lt;span class="req"&gt;@Html.Raw("*")&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div class="M-editor-field"&gt;
                          @Html.TextBoxFor(model =&gt; model.AgentId, new { maxlength = 8 })
                      &lt;/div&gt;
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>                &lt;div class="M-editor-label"&gt;
                      &lt;label for="RefNumber"&gt;Reference Number&lt;/label&gt;
                      &lt;span class="alwaysReq" style="display: inline;"&gt; *&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class="M-editor-field"&gt;
                      &lt;input class="staticData" id="RefNumber" maxlength="9" name="RefNumber" type="text" value=""&gt;
                  &lt;/div&gt;
                  &lt;div class="M-editor-label"&gt;
                      &lt;label for="OwnerMasterAgentId"&gt;Owner Master Agent Id&lt;/label&gt;
                      &lt;span class="req" style="display: inline;"&gt;*&lt;/span&gt; 
                  &lt;/div&gt;
                  &lt;div class="M-editor-field"&gt;
                      &lt;input class="staticData" id="OwnerMasterAgentId" maxlength="8" name="OwnerMasterAgentId" type="text" value=""&gt;
                  &lt;/div
                      &lt;div class="M-editor-label"&gt;
                          &lt;label for="AccountNumber"&gt;Account Number&lt;/label&gt;
                          &lt;span class="req" style="display: inline;"&gt;*&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div class="M-editor-field"&gt;
                          &lt;input id="AccountNumber" maxlength="17" name="AccountNumber" type="text" value=""&gt;
                      &lt;/div&gt;
                      &lt;div class="M-validator-field"&gt;
                          &lt;span class="field-validation-valid" data-valmsg-for="AccountNumber" data-valmsg-replace="true" style="display: none;"&gt;&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div class="M-editor-label"&gt;
                          &lt;label for="AgentId"&gt;Agent ID&lt;/label&gt;
                          &lt;span class="req" style="display: inline;"&gt;*&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div class="M-editor-field"&gt;
                          &lt;input id="AgentId" maxlength="8" name="AgentId" type="text" value=""&gt;
                      &lt;/div&gt;
  </code></pre>