title: How to apply regular expression for Date format MM/DD/YYYY HH:MM:SS am/pm in ASP.NET
body: <p>I have a TextBox where I am taking input from as user as <strong><code>dd/mm/yyyy hh:mm:ss</code></strong>. Now, I want to validate it with a regular expression. I'm not sure how to apply the expression. I have attached my code as well.</p>
  
  <pre><code>  &lt;tr&gt;
        &lt;td style="width: 30%" class="EcommLabel"&gt;
            Date From
        &lt;/td&gt;
        &lt;td style="width: 70%" class="EcommLabel"&gt;
            &lt;asp:TextBox ID="txtDateFrom" CssClass="EcommNormalTextBox" runat="server"&gt;
            &lt;/asp:TextBox&gt;MM/DD/YYYY&lt;br /&gt;
  
        &lt;%-- &lt;asp:RegularExpressionValidator ID="regDateFrom" ValidationExpression="^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$" ControlToValidate="txtDateFrom" ValidationGroup="Promotion" runat="server" ErrorMessage="Invalid Date"&gt;&lt;/asp:RegularExpressionValidator&gt;--%&gt;
  
        &lt;asp:RangeValidator runat="server" ID="rvDateFrom" Type="Date" ControlToValidate="txtDateFrom" MaximumValue="3000/12/31" MinimumValue="2000/1/1" ErrorMessage="Invalid Date" Display="Dynamic" ValidationGroup="Promotion" /&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>