title: HTML5 required="" attribute with .NET webforms
body: <p>I'm trying to use the new <code>required</code> attribute on form fields in my .NET 4.5 webforms application.</p>
  
  <p>However, since there is only one <code>&lt;form&gt;</code> surrounding all the controls on the page (webforms style), the browser does not know which fields to be validated when a submit button is pressed.</p>
  
  <p>A stripped version of a page with both login functionality and a page search is attached below.</p>
  
  <p>When I click the Search button my browser tell me that i have to fill in the username and password fields first. And when I try to login it tells me I have to enter some text in the search field. Because all of the fields are children of the same <code>&lt;form&gt;</code> tag.</p>
  
  <p>Any one else had this problem or came up with a solution? I would like to use the HTML5 attributes for form validation, no javascript solution.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form method="post" runat="server" id="mainform"&gt;
  
  
      &lt;%// Search %&gt;
      &lt;asp:Panel runat="server" DefaultButton="searchButton" &gt;
  
        &lt;asp:TextBox runat="server" ID="searchQuery" ClientIDMode="Static" required="required" /&gt;
        &lt;asp:Button runat="server" ID="searchButton" ClientIDMode="Static" Text="Search"/&gt;
  
      &lt;/asp:Panel&gt;
  
  
      &lt;%// Login %&gt;
      &lt;asp:Panel runat="server" DefaultButton="signInButton"&gt;
  
        &lt;label for="inputusername"&gt;Username&lt;/label&gt;
        &lt;asp:TextBox runat="server" ClientIDMode="Static" ID="inputusername" required="required" /&gt;
  
        &lt;label for="inputpassword"&gt;Password&lt;/label&gt;
        &lt;asp:TextBox runat="server" TextMode="Password" ClientIDMode="Static" ID="inputpassword" required="required" /&gt;
  
        &lt;asp:Button ID="signInButton" runat="server" /&gt;
  
      &lt;/asp:Panel&gt;
  
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;/html&gt;
  </code></pre>