title: Jquery to append text in textbox from other textboxes in the same Mvc view
body: <p>I have 3 textboxes on a form in my mvc view, FirstName, LastName, UserName.  The UserName needs to be the FirstName + LastName.  I tried the following Jquery which will add the letters of the FirstName field to UserName on the FirstName.KeyUp event, but when I add letters from the LastName field to the UserName it overwrites the FirstName letters (actually I only need the 1st letter of the lastName).  What is the Jquery for this to "Append" letters and not overwrite?  Is KeyUp a good event for this -- maybe LostFocus or something?  Or should I use a function that returns a value with the return keyword?  What is the Jquery for that approach?</p>
  
  <pre><code>@using (Html.BeginForm()) {
  
      &lt;fieldset&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.FirstName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.FirstName)
              @Html.ValidationMessageFor(model =&gt; model.FirstName)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.LastName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.LastName)
              @Html.ValidationMessageFor(model =&gt; model.LastName)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.UserName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.UserName)
              @Html.ValidationMessageFor(model =&gt; model.UserName)
          &lt;/div&gt;
      &lt;/fieldset&gt;
  }
  
  
  &lt;script type="text/javascript"&gt;
  
      $(function () {
  
          $("#FirstName").keyup(function () {            
              $("#UserName").val(this.value);
          });
          $("#LastName").keyup(function () {
              $("#UserName").val(this.value);
          });
  
      });
  
  &lt;/script&gt;
  </code></pre>