title: Add Form control class to a dynamically create Textbox in MCV
body: <p>I am trying to add a form control class to a dynamically textboxt created using javascript</p>
  
  <p>View</p>
  
  <pre><code>&lt;div class="form-group"&gt;
  @Html.Label("Mobile Number", new { @class = "control-label col-md-2  
    required" 
   })
  &lt;div class="col-md-5" id="firstdiv"&gt;
    &lt;input type="text" name="mobilenumber" class="form-control" id="txtMobile" 
    onchange="phonenumber()" /&gt;
  
  &lt;/div&gt;
    &lt;div class="col-md-2"&gt;
     &lt;button type="button" onclick="AddTextBox();"&gt;&lt;img 
    src="~/Content/Images/SendIT/plus2.jpg"&gt;&lt;/button&gt;
  
     &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Javascript Code</p>
  
  <pre><code>function GetDynamicTextBox(value) {
          var div = $("&lt;div /&gt;");
  
          var textBox = $("&lt;input /&gt;").attr("type", "textbox").attr("name", "mobilenumber");
  
          textBox.val(value);
          div.append(textBox);
  
          var button = $("&lt;input /&gt;").attr("type", "button").attr("value", "Remove");
          button.attr("onclick", "RemoveTextBox(this)");
          div.append(button);
  
          return div;
      }
      function AddTextBox() {
          var div = GetDynamicTextBox("");
          $("#firstdiv").append(div);
      }
  
      function RemoveTextBox(button) {
          $(button).parent().remove();
      }
  </code></pre>
  
  <p>The problem I am having is when I click on the image button the dynimically textbox displayed but not in the same format as the first textbox. Thanks for your help</p>