Client side custom validation
<p>I have a text box to hold phone number and drop down list that lists mobile providers. I am trying to make sure that both are selected. I use a customer validator with client side validation, using a validation group. Same validation group is assigned to an "Update" button.</p>

<p>When I add phone number and no mobile provider, or vice versa, an error message is displayed as soon as control loses focus. But if I click the "Update" button, no error is displayed and update happily goes on updating. Can't see what I am doing wrong. None of the textbox or drop down have autopostback set.</p>

<pre><code>function ValidateMobile(oSrc, args) {
    var tbMobile = document.getElementById('&lt;%=tbMobile.ClientID%&gt;');
    var ddlMobileProvider = document.getElementById('&lt;%=ddlMobileProvider.ClientID%&gt;');
    args.IsValid = true;
    var mobileNum = tbMobile.value.trim();
    var selectedCarrierValue = ddlMobileProvider.options[ddlMobileProvider.selectedIndex].value;

    if ((mobileNum != "" &amp;&amp; selectedCarrierValue == "") || (mobileNum == "" &amp;&amp; selectedCarrierValue != ""))
        args.IsValid = false;
}

&lt;asp:TextBox runat="server" ID="tbMobile" CssClass="NormalSmall" Width="95%" /&gt;
&lt;ajaxToolkit:MaskedEditExtender runat="server" ID="mtbMobile" TargetControlID="tbMobile" Mask="(999) 999-9999" /&gt;

&lt;asp:DropDownList runat="server" ID="ddlMobileProvider" Width="95%" DataSourceID="odsMobileProviders" DataTextField="CARRIERNAME"  DataValueField="MOBILECARRIERID" AppendDataBoundItems="true"&gt;
    &lt;asp:ListItem Text="Select Mobile Provider ..." Value="" /&gt;
&lt;/asp:DropDownList&gt;

&lt;asp:ImageButton runat="server" ID="ibUpdate"  ImageUrl="~/assets/images/buttons/Update.png" OnClick="ibUpdate_Click"  CausesValidation="true" ValidationGroup="vgCustInfo" /&gt;

&lt;asp:CustomValidator runat="server" ID="cvMobile"  ControlToValidate="tbMobile" Display="Dynamic" ValidationGroup="vgCustInfo"  ClientValidationFunction="ValidateMobile" ErrorMessage="Both Carrier and Mobile Number must be specified"&gt;&lt;/asp:CustomValidator&gt;
</code></pre>