A
Alan Silver
Hello,
I have a custom validator on my page, and have the server-side code
working fine. I want to add a client-side funtion as well, but am not
sure how to wire it in so that it works with the other validators on the
page.
I specified the name of the Javascript function with the
ClientValidationFunction attribute of the custom validator, and it is
being called fine. However, if the validator returns false (ie bad
data), nothing happens on the client. With the other validators, I get a
message box popping up with the warnings, and I get the red text by the
control so the user can see which control fired the error.
How do I get the custom validator to do this? Here is the server tag...
<asp:CustomValidator ControlToValidate="txtDeliveryCountries"
OnServerValidate="ValidateTxtDeliveryCountries"
ClientValidationFunction="ValidateTxtDeliveryCountriesJS"
Display="Dynamic" Text="At least one country name does not start with
U_, E_ or W_" Runat="Server" />
(the point of the validator is that it checks a multiline textbox, that
is supposed to contain a list of countries, each of which has one of U_,
E_ or W_ as a prefix. The validator checks to make sure they didn't
enter a country without a prefix, or one with an invalid prefix).
TIA
I have a custom validator on my page, and have the server-side code
working fine. I want to add a client-side funtion as well, but am not
sure how to wire it in so that it works with the other validators on the
page.
I specified the name of the Javascript function with the
ClientValidationFunction attribute of the custom validator, and it is
being called fine. However, if the validator returns false (ie bad
data), nothing happens on the client. With the other validators, I get a
message box popping up with the warnings, and I get the red text by the
control so the user can see which control fired the error.
How do I get the custom validator to do this? Here is the server tag...
<asp:CustomValidator ControlToValidate="txtDeliveryCountries"
OnServerValidate="ValidateTxtDeliveryCountries"
ClientValidationFunction="ValidateTxtDeliveryCountriesJS"
Display="Dynamic" Text="At least one country name does not start with
U_, E_ or W_" Runat="Server" />
(the point of the validator is that it checks a multiline textbox, that
is supposed to contain a list of countries, each of which has one of U_,
E_ or W_ as a prefix. The validator checks to make sure they didn't
enter a country without a prefix, or one with an invalid prefix).
TIA