title: server-side mvc3 validation for form not working
body: <p>I have a form in my View. The fields on the form are derived from the Model. 
  I have just given a single variable to shorten the code here.</p>
  
  <pre><code>MODEL:
  public class abc
  {
      [Required]
      public string name { get; set; }
  }
  
  VIEW:
  &lt;body onload="SetButton()"&gt;
  @using (Html.BeginForm("myaction","mycontroller",FormMethod.POST, new {id="myform"}))
  {
      @Html.TextBoxFor(m=&gt;m.name)
      @Html.ValidationMessageFor(m=&gt;m.name)
  }
  &lt;/body&gt;
  &lt;script type="text/javascript"&gt;
  function SetButton{
      document.getElementById("button").innerHTML='&lt;input type="submit" value="Next"             style="width:90px" onclick="myform.submit()"/&gt;';
  }
  &lt;/script&gt;
  
  Layout Page:
  &lt;div id="button"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>On clicking the 'Next' button, validation does not occur. The form gets submitted even if there is nothing entered for 'name' field.If the button is put inside the Form(myform), validation works.Why isn't the validation working for the code shown?</p>