clientvalidation in asp.net
<p>I am trying to create a required field validation with a customvalidator. However when the field is empty it still does a postback?</p>

<pre><code>&lt;body&gt;
    &lt;form id="Form1" runat="server"&gt;
    &lt;h3&gt;
        CustomValidator ServerValidate Example&lt;/h3&gt;
    &lt;asp:Label ID="Message" Font-Name="Verdana" Font-Size="10pt" runat="server" /&gt;
    &lt;p&gt;
        &lt;asp:TextBox ID="Text1" runat="server" Text="[Name:required]" /&gt;
        &amp;nbsp;&amp;nbsp;
        &lt;asp:CustomValidator ID="CustomValidator1" ControlToValidate="Text1" ClientValidationFunction="ClientValidate"
            Display="Static" ErrorMessage="" ForeColor="green" Font-Name="verdana" Font-Size="10pt"
            runat="server" /&gt;
        &lt;p&gt;
            &lt;asp:Button ID="Button1" Text="Validate" OnClick="ValidateBtn_OnClick" runat="server" /&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;script language="javascript"&gt;
    function ClientValidate(source, arguments) {
        alert(arguments.Value.length);
        if (arguments.Value != "[Name:required]" &amp;&amp; arguments.Value.length &gt; 0) {
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
    }
&lt;/script&gt;
</code></pre>
