I have a page where the user enters address data. They can select a country from a drop down list. Depending on what country is selected, the user enters their province/state by either a textbox or a drop down list.
If they select USA/Canada, a drop down list is populated with the states/provinces and made visible, while the state textbox is made invisible. If they select a country other than USA/Canada, the state drop down list is made invisible, and a state textbox is made visible. The first item in the drop down list is "select your state/province" with a value of "".
I want to use a custom validator to validate the user's state selection. I am working on my javascript validation script, and currently have no server-side validation. The problem is, if the user leaves the state unselected, or changes from a valid state selection to "select your state/province", the validation function never gets called.
here is my validator:
here is my validation function:Code:<asp:CustomValidator ID="cvState" runat="server" ClientValidationFunction="validateStateSelection" ErrorMessage="* Required" ControlToValidate="ddlCountry" ValidateEmptyText="True"></asp:CustomValidator></td>
Code:function validateStateSelection(source, arguments) { alert("client validation func called"); alert(arguments.Value); if(arguments.Value == null || arguments.Value == "") { arguments.IsValid = false; return; } arguments.IsValid = true; }


Reply With Quote
Bookmarks