Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check that you have the your <code>CustomValidator</code> property <code>ValidateEmptyText</code> set to <code>true</code> so that empty text will be validated. Then you will not need the <code>RequiredFieldValidator</code> anymore.</p> <p><strong>EDIT:</strong> I took your code and copy and pasted it into an empty project and it works as expected. There must be something you have not posted, or is posting incorrectly, that we are not aware of. Is there anything else that affects the button that is triggering the validation or the validation controls themselves?</p> <p><strong>EDIT:</strong> Here is the exact code (it's in a content page):</p> <p>aspx page:</p> <pre><code>&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt; &lt;asp:TextBox ID="txtPRI" runat="server" Width="295" /&gt;&lt;br /&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" display="Dynamic" CssClass="leftAlign" SetFocusOnError="true" runat="server" controltovalidate="txtPRI" errormessage="Please enter your PRI" /&gt; &lt;asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtPRI" onservervalidate="cusCustom_ServerValidate" Enabled="true" ValidateEmptyText="true" display="Dynamic" CssClass="leftAlign" SetFocusOnError="true" errormessage="The text must be exactly 8 characters long!" /&gt; &lt;/asp:Content&gt; </code></pre> <p>.cs page (empty <code>Page_Load</code>):</p> <pre><code>protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e) { // put a break point here and it stops on it if (e.Value.Length == 8) e.IsValid = true; else e.IsValid = false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload